我需要从后台服务重新启动我的主活动。我通过BroadcastReceiver获得我的服务结果,我需要在执行一些操作后恢复它。
这可能吗?我该怎么做?
我尝试了这个解决方案Resume application and stack from notification,但对我不起作用。
编辑:
这是我的接收器:
这可能吗?我该怎么做?
我尝试了这个解决方案Resume application and stack from notification,但对我不起作用。
编辑:
这是我的接收器:
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();
}
}
}
};