我需要从后台服务重新启动我的主要活动。
我通过 BroadcastReceiver 获得了我的服务结果,我需要恢复它(经过一些操作)。
可能吗 ?
我怎样才能做到这一点 ?
我尝试了此解决方案从通知中恢复应用程序和堆栈,但它对我不起作用。
编辑:
那是我的接收器:
private BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
          Bundle bundle = intent.getExtras();
          if (bundle != null) {
            int resultCode = bundle.getInt(DownloadService.RESULT);
            if (resultCode == RESULT_OK) {
                Log.i("MyApp", "RESULT OK");
                final Intent mainIntent = new Intent(context, MainActivity.class);
                mainIntent.setAction(Intent.ACTION_MAIN);
                mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                startActivity(mainIntent);
            } else {
              Toast.makeText(MainActivity.this, "KO",Toast.LENGTH_LONG).show();
            }
          }
        }
 };