我有以下错误但无法确定有效的解决方案:
02-17 22:58:21.636 27014-27014/com.example.feastapp E/ActivityThread﹕ Pause GC
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at android.app.ActivityThread.pauseGC(ActivityThread.java:5410)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2277)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
at android.app.ActivityThread.access$900(ActivityThread.java:169)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5487)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsatisfiedLinkError: Native method not found: dalvik.system.VMRuntime.pauseGc:(Ljava/lang/String;)I
at dalvik.system.VMRuntime.pauseGc(Native Method)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at android.app.ActivityThread.pauseGC(ActivityThread.java:5410)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2277)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
at android.app.ActivityThread.access$900(ActivityThread.java:169)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5487)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
导致错误的操作是发送消息操作,特别是在行imService.sendGroupMessage
上:
// Send message
sendButton.setOnClickListener(new View.OnClickListener() {
CharSequence message;
Handler handler = new Handler();
@Override
public void onClick(View v) {
if (selectedLocationId == null) {
selectedLocationId = "0";
}
Thread thread = new Thread() {
public void run() {
try {
if (imService.sendGroupMessage(group.groupId,
group.groupName, enteredMessage.getText().toString(), sharedSpecialId, selectedLocationId) == null) {
handler.post(new Runnable() {
public void run() {
Toast.makeText(
getApplicationContext(),
R.string.message_cannot_be_sent,
Toast.LENGTH_LONG).show();
}
});
}
} catch (UnsupportedEncodingException e) {
Toast.makeText(getApplicationContext(),
R.string.message_cannot_be_sent,
Toast.LENGTH_LONG).show();
e.printStackTrace();
} catch (NullPointerException e) {
Toast.makeText(getApplicationContext(),
"It's null...",
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
};
thread.start();
}
});
我确实通过以下方式将活动绑定到创建服务:
private Manager imService;
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
imService = ((MessagingService.IMBinder) service).getService();
}
public void onServiceDisconnected(ComponentName className) {
imService = null;
Toast.makeText(SharingAction.this, R.string.local_service_stopped,
Toast.LENGTH_SHORT).show();
}
};
为什么会出现此错误,当我有其他类设置时,没有错误?