Android:Calling startActivity() from outside of an Activity context错误
16lz
2021-01-23
出现提示:
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
可能在一个Service中启动一个Acitivity:加上FLAG_ACTIVITY_NEW_TASK
String fileName = task.getFullFileName();Intent intent = new Intent(Intent.ACTION_VIEW);intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive");this.getApplicationContext().startActivity(intent);
更多相关文章
- Android消息提示Toast的使用总结
- AutoCompleteTextView(自动提示)
- android中,handler处理信息中弹出提示框注意事项
- Android Room,编译成功,倒是 build APK 失败提示: 无法访问:Activity
- 实现 Android 通知提示功能
- [Tools]Android Studio代码提示功能--Ctrl+Alt+Space(空格键)
- android使用AlertDialog提示 Unable to add window -- token nul
- Android Studio xml android标签突然没有代码提示问题的解决