我的Android应用程序给我一个错误,说“我的应用程序不幸停止了” 检查logcat后,我发现没有注册错误。 我认为错误存在于服务本身内,但我可能错了。 任何帮助将不胜感激。
代码:
public class MyService extends Service {
public MyService() {
}
@Override
public IBinder onBind(Intent arg0) {
return null;}
@Override
public void onCreate() {
Toast.makeText(this, "Congrats! Blocker Created", Toast.LENGTH_LONG).show();
}
@Override
public void onStart(final Intent intent, int startId) {
Timer t = new Timer();
t.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> tasks = activityManager.getRunningTasks(Integer.MAX_VALUE);
ActivityManager.RunningTaskInfo ar = tasks.get(0);
String activityOnTop=ar.topActivity.getClassName();
Intent lockIntent = new Intent(MyService.this, LockScreen.class);
lockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ComponentName componentInfo = tasks.get(0).topActivity;
Intent myLock=new Intent(MyService.this,LockScreen.class);
List data=(ArrayList) intent.getExtras().getStringArrayList("Caller2");
myLock.putStringArrayListExtra("Caller3",(ArrayList<String>)data);
myLock.putExtra("intCall2",(int)intent.getExtras().get("intCall"));
if(!componentInfo.getPackageName().equals("com.example.epiclapser.noprocrastinate"))
{
startActivity(myLock);
Log.v("iwashere", "-- ACTIVITY --");
}
}
},
Toast.makeText(this, "My Blocker Started", Toast.LENGTH_LONG).show();
}
logcat的:
01-29 10:34:45.849 1251-1251/com.example.epiclapser.noprocrastinate D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
01-29 10:34:46.728 1251-1251/com.example.epiclapser.noprocrastinate D/libEGL﹕ loaded /system/lib/egl/libEGL_emulation.so
01-29 10:34:46.759 1251-1251/com.example.epiclapser.noprocrastinate D/﹕ HostConnection::get() New Host Connection established 0x2a1eaca0, tid 1251
01-29 10:34:46.789 1251-1251/com.example.epiclapser.noprocrastinate D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_emulation.so
01-29 10:34:46.809 1251-1251/com.example.epiclapser.noprocrastinate D/libEGL﹕ loaded /system/lib/egl/libGLESv2_emulation.so
01-29 10:34:46.980 1251-1251/com.example.epiclapser.noprocrastinate W/EGL_emulation﹕ eglSurfaceAttrib not implemented
01-29 10:34:47.019 1251-1251/com.example.epiclapser.noprocrastinate D/OpenGLRenderer﹕ Enabling debug mode 0
01-29 10:38:36.479 1359-1359/com.example.epiclapser.noprocrastinate I/dalvikvm﹕ Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
01-29 10:38:36.479 1359-1359/com.example.epiclapser.noprocrastinate W/dalvikvm﹕ VFY: unable to resolve virtual method 11352: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
01-29 10:38:36.489 1359-1359/com.example.epiclapser.noprocrastinate D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
01-29 10:38:36.499 1359-1359/com.example.epiclapser.noprocrastinate I/dalvikvm﹕ Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
01-29 10:38:36.499 1359-1359/com.example.epiclapser.noprocrastinate W/dalvikvm﹕ VFY: unable to resolve virtual method 11358: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
01-29 10:38:36.499 1359-1359/com.example.epiclapser.noprocrastinate D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
01-29 10:38:36.519 1359-1359/com.example.epiclapser.noprocrastinate I/dalvikvm﹕ Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
01-29 10:38:36.519 1359-1359/com.example.epiclapser.noprocrastinate W/dalvikvm﹕ VFY: unable to resolve virtual method 9046: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
01-29 10:38:36.519 1359-1359/com.example.epiclapser.noprocrastinate D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000e
01-29 10:38:36.559 1359-1359/com.example.epiclapser.noprocrastinate I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
01-29 10:38:36.589 1359-1359/com.example.epiclapser.noprocrastinate W/dalvikvm﹕ VFY: unable to resolve virtual method 368: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
01-29 10:38:36.589 1359-1359/com.example.epiclapser.noprocrastinate D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
01-29 10:38:36.610 1359-1359/com.example.epiclapser.noprocrastinate I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
01-29 10:38:36.610 1359-1359/com.example.epiclapser.noprocrastinate W/dalvikvm﹕ VFY: unable to resolve virtual method 390: Landroid/content/res/TypedArray;.getType (I)I
01-29 10:38:36.619 1359-1359/com.example.epiclapser.noprocrastinate D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
01-29 10:38:37.189 1359-1359/com.example.epiclapser.noprocrastinate D/libEGL﹕ loaded /system/lib/egl/libEGL_emulation.so
01-29 10:38:37.209 1359-1359/com.example.epiclapser.noprocrastinate D/﹕ HostConnection::get() New Host Connection established 0x2a1ea5f8, tid 1359
01-29 10:38:37.229 1359-1359/com.example.epiclapser.noprocrastinate D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_emulation.so
01-29 10:38:37.249 1359-1359/com.example.epiclapser.noprocrastinate D/libEGL﹕ loaded /system/lib/egl/libGLESv2_emulation.so
01-29 10:38:37.388 1359-1359/com.example.epiclapser.noprocrastinate W/EGL_emulation﹕ eglSurfaceAttrib not implemented
01-29 10:38:37.419 1359-1359/com.example.epiclapser.noprocrastinate D/OpenGLRenderer﹕ Enabling debug mode 0
01-29 10:38:45.759 1359-1359/com.example.epiclapser.noprocrastinate D/dalvikvm﹕ GC_FOR_ALLOC freed 258K, 14% free 2761K/3180K, paused 256ms, total 300ms
01-29 10:38:45.988 1359-1359/com.example.epiclapser.noprocrastinate D/dalvikvm﹕ GC_FOR_ALLOC freed 89K, 14% free 2821K/3280K, paused 60ms, total 68ms