-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
example运行起来后报错,我把代码集成到项目以后,setAlias同样报错 #14
Comments
一样的 大佬 你解决了么? |
修改result运行在主线程,自定义MainThreadResult类实现MethodChannel.Result接口 class MainThreadResult implements MethodChannel.Result {
private MethodChannel.Result result;
private Handler handler;
MainThreadResult(MethodChannel.Result result) {
this.result = result;
handler = new Handler(Looper.getMainLooper());
}
@Override
public void success(final Object o) {
handler.post(
new Runnable() {
@Override
public void run() {
result.success(o);
}
});
}
@Override
public void error(
final String errorCode, final String errorMessage, final Object errorDetails) {
handler.post(
new Runnable() {
@Override
public void run() {
result.error(errorCode, errorMessage, errorDetails);
}
});
}
@Override
public void notImplemented() {
handler.post(
new Runnable() {
@Override
public void run() {
result.notImplemented();
}
});
}
} 在 @Override
public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
super.onAliasOperatorResult(context, jPushMessage);
int sequence = jPushMessage.getSequence();
Result callback = JPushPlugin.instance.callbackMap.get(sequence);
if (callback == null) {
Log.i("JPushPlugin", "Unexpected error, callback is null!");
return;
}
++ callback = new MainThreadResult(callback);
if (jPushMessage.getErrorCode() == 0) { // success
Map<String, Object> res = new HashMap<>();
res.put("alias", (jPushMessage.getAlias() == null) ? "" : jPushMessage.getAlias());
callback.success(res);
} else {
callback.error(Integer.toString(jPushMessage.getErrorCode()), "", "");
}
JPushPlugin.instance.callbackMap.remove(sequence);
} |
能把这问题rp吗 |
@jzoom 能把这问题pr了吗 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
D/FlutterJPushPlugin(30870): MyJPushMessageReceiver init
E/AndroidRuntime(30870): FATAL EXCEPTION: MessageReceiver
E/AndroidRuntime(30870): Process: com.jzoom.pushtest, PID: 30870
E/AndroidRuntime(30870): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: MessageReceiver
E/AndroidRuntime(30870): at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:605)
E/AndroidRuntime(30870): at io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageResponseCallback(FlutterJNI.java:556)
E/AndroidRuntime(30870): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:131)
E/AndroidRuntime(30870): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:225)
E/AndroidRuntime(30870): at com.jzoom.flutterjpush.FlutterJPushPlugin$MyJPushMessageReceiver.onAliasOperatorResult(FlutterJPushPlugin.java:766)
E/AndroidRuntime(30870): at cn.jpush.android.a.b.run(Unknown Source:90)
E/AndroidRuntime(30870): at android.os.Handler.handleCallback(Handler.java:808)
E/AndroidRuntime(30870): at android.os.Handler.dispatchMessage(Handler.java:101)
E/AndroidRuntime(30870): at android.os.Looper.loop(Looper.java:166)
E/AndroidRuntime(30870): at android.os.HandlerThread.run(HandlerThread.java:65)
I/HwCust (30870): Constructor found for class android.net.HwCustConnectivityManagerImpl
D/HwCust (30870): Create obj success use class android.net.HwCustConnectivityManagerImpl
I/HwApiCacheMangerEx(30870): apicache pi null
I/HwApiCacheMangerEx(30870): apicache pi PackageInfo{db15c83 com.jzoom.pushtest}
D/NetworkSecurityConfig(30870): No Network Security Config specified, using platform default
I/Process (30870): Sending signal. PID: 30870 SIG: 9
The text was updated successfully, but these errors were encountered: