我想把应用程序带到开发者选项屏幕

时间:2018-02-03 07:03:57

标签: android

这是我的代码(没有XML代码)。 我希望我的应用程序将带我进入开发人员选项屏幕。 但它会产生错误并完成该应用程序。为什么会出现错误? 我该怎么办?

public class MainActivity extends AppCompatActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Handler hd = new Handler();
        hd.postDelayed(new goOption(), 2000);
    }

    private class goOption implements Runnable{
        public void run() {
            startActivityForResult(new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS), 0);
            ActivityCompat.finishAffinity(MainActivity.this);
        }
    }
}
当它在API 25上运行时,

是logcat文本。 (和图像)

enter image description here

02-03 07:01:01.728 2562-2614/com.google.android.gms E/ConfigFileUtils: Failed to read config file: /data/user_de/0/com.google.android.gms/app_chimera/current_modulesets.pb (No such file or directory)
02-03 07:01:01.809 2970-2970/com.google.android.gm E/ActivityThread: Service com.android.email.service.EmailBroadcastProcessorService has leaked ServiceConnection blt@1e059b0 that was originally bound here
 android.app.ServiceConnectionLeaked: Service com.android.email.service.EmailBroadcastProcessorService has leaked ServiceConnection blt@1e059b0 that was originally bound here
     at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:1336)
     at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:1231)
     at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1450)
     at android.app.ContextImpl.bindService(ContextImpl.java:1422)
     at android.content.ContextWrapper.bindService(ContextWrapper.java:636)
     at blr.a(SourceFile:243)
     at blr.d(SourceFile:286)
     at bft.c(SourceFile:179)
     at bdk.a(SourceFile:202)
     at bdk.a(SourceFile:146)
     at com.android.email.service.EmailBroadcastProcessorService.c(SourceFile:348)
     at com.android.email.service.EmailBroadcastProcessorService.onHandleIntent(SourceFile:1333)
     at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:68)
     at android.os.Handler.dispatchMessage(Handler.java:102)
     at android.os.Looper.loop(Looper.java:154)
     at android.os.HandlerThread.run(HandlerThread.java:61)
02-03 07:01:01.809 2970-2970/com.google.android.gm I/Exchange: RestartPingsTask did not start any pings.
02-03 07:01:01.810 2970-2970/com.google.android.gm I/Exchange: onDestroy
02-03 07:01:01.815 2970-3015/com.google.android.gm E/bkv: RuntimeException when trying to unbind from service
  java.lang.IllegalArgumentException: Service not registered: blt@1e059b0
      at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1289)
      at android.app.ContextImpl.unbindService(ContextImpl.java:1483)
      at android.content.ContextWrapper.unbindService(ContextWrapper.java:648)
      at blu.a(SourceFile:186)
      at blu.doInBackground(SourceFile:173)
      at android.os.AsyncTask$2.call(AsyncTask.java:305)
      at java.util.concurrent.FutureTask.run(FutureTask.java:237)
      at android.os.Handler.handleCallback(Handler.java:751)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:154)
      at android.os.HandlerThread.run(HandlerThread.java:61)

1 个答案:

答案 0 :(得分:0)

试试这个

public class MainActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                startActivity(new Intent(android.provider.Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS));
            }
        }, 2000);


    }
}