java - 新 Intent 未从服务开始(尝试了 Google 的所有解决方案)

标签 java android android-studio

以下是我的 Activity 在 AndroidManifest.xml 文件中的定义方式:-

<activity android:name=".MyDialog"
            android:launchMode="singleTask"
            android:theme="@android:style/Theme.Dialog"/>

我的服务是如何定义的:-

  <service
        android:name=".ChatHeadService"
        android:process=":chatHead"/>

我如何从服务中调用它:-

Intent intent = new Intent(this, MyDialog.class);
intent.setAction(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

Activity 仍然没有开始!请帮忙。谢谢:)

最佳答案

来自Service类内部

Intent intent = new Intent(this, MyDialog.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent );

关于java - 新 Intent 未从服务开始(尝试了 Google 的所有解决方案),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30928940/

相关文章:

android - SDk更新后,Android Studio无法找到org.apache.http.legacy

android - 无法将更新的 APK 上传到 Google Play 商店

java - 无法通过单击 Android Studio 中的抽屉项目来加载新 fragment

java - 查找 Java JButton 数组的索引

java - 这个代码模式的目的是什么?

java - 如何在android中通过引用传递对象以更改原始对象?

java - 无法解码流: java. io.FileNotFoundException:

android - ListView 整个列表获取选定的颜色而不是子项

Java 对象序列化 java.io.UTFDataFormatException

Android 登录 Activity 和主页 Activity 重定向