[英]Could not startActivity from service in android oreo
My App Crash due to start activity from service. 我的应用程式由于服务中的启动活动而当机。
Is there any way to startActivity from service in Android Api 26(oreo) version i am using below code to start activity* 有什么办法可以从Android Api 26(oreo)版本的服务中启动startActivity,我正在使用以下代码启动活动*
Intent stopDialog=new Intent(this, DialogActivity.class);
stopDialog.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
stopDialog.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(stopDialog);
Make sure your Activity
is mentioned in AndroidMenifest.xml
file. 确保
AndroidMenifest.xml
文件中提到了您的Activity
。 If this is mentioned then try this: 如果提及此问题,请尝试以下操作:
Intent stopDialog = new Intent();
stopDialog.setClass(this, DialogActivity.class);
stopDialog.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(stopDialog);
finally i have solved my problem myself i was using orientation in activity which is starting from service and logcat says me you can use orientation only in fullscreen activity 最终我自己解决了我的问题,我从服务开始就在活动中使用定向,logcat说我只能在全屏活动中使用定向
Here is solution i have removed orientation tag from activity 这是我已从活动中删除方向标签的解决方案
<activity
android:name=".DialogActivity"
android:excludeFromRecents="true"
android:launchMode="singleTop"
android:theme="@style/MyDialogTheme">
</activity>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.