这是我的Android清单文件:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".view.MainActivity"
android:label="@string/app_name"
android:screenOrientation="reverseLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<data
android:host="mocha"
android:path="/RTT/reset"
android:scheme="content" />
</intent-filter>
</activity>
<activity
android:name="ihpc.mocha.fakertt.view.SessionTimeOutActivity"
android:label="@string/app_name"
android:screenOrientation="reverseLandscape">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="mocha"
android:path="/RTT/sessionTimeOut"
android:scheme="content" />
</intent-filter>
</activity>
</application>
这表示我在此处注册了隐式意图。
<data android:host="mocha"
android:path="/RTT/reset"
android:scheme="content" />
现在,当我从另一个应用程序中调用它时。
Intent gameInfoIntent = new Intent(Intent.ACTION_VIEW);
gameInfoIntent.setData(Uri.parse("content://mocha/RTT"
+ "/reset"));
gameInfoIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PackageManager packageManager = getPackageManager();
List<ResolveInfo> activities = packageManager
.queryIntentActivities(gameInfoIntent, 0);
boolean isIntentSafe = activities.size() > 0;
if (isIntentSafe) {
startActivity(gameInfoIntent);
finish();
} else {
}
目前没有找到任何相关活动。
"content://mocha/RTT/reset"
我尝试从同一个活动中调用此代码进行测试,但结果相同。
请建议我在哪里以及我做错了什么?
更新:
我通过在评论中放置建议的代码来调用会话超时活动。
我已像这样更新了我的清单:
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="mocha"
android:path="/RTT/reset"
android:scheme="content" />
</intent-filter>
</activity>
<activity
android:name="ihpc.mocha.fakertt.view.SessionTimeOutActivity"
android:label="@string/app_name"
android:screenOrientation="reverseLandscape">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="mocha"
android:path="/RTT/sessionTimeOut"
android:scheme="content" />
</intent-filter>
</activity>
</application>
但是我仍然无法调用主活动。
MainActivity
添加<category android: name =“android.intent.category.BROWSABLE”/>
和<action android: name =“android.intent.action.VIEW”/>
。 - Vladimir Mironov