Ankit HTech
Ankit HTech

Reputation: 1893

Implicit intent is not called in android

Here is my android manifest file:

<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>

It shows that I have registered implicit intent here

<data android:host="mocha"
 android:path="/RTT/reset"
 android:scheme="content" />

Now when I call it from another app

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 {
                }

It is showing no activity found for

"content://mocha/RTT/reset"

I tried calling this code form same activity as well for testing purpose but result is same.

Please suggest me where and what I am doing wrong?

UPDATE:

I am able to call session time out activity by putting suggested code in the comments. I have updated my manifest like this:

            <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>

But I am still unable to call main activity.

Upvotes: 4

Views: 1388

Answers (1)

Ankit HTech
Ankit HTech

Reputation: 1893

I have resolved my problem by adding below lines to my manifest file

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />

Here is my new look manifest file

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="ihpc.mocha.rtt"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="12" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:theme="@android:style/Theme.NoTitleBar" >
        <activity
            android:name="ihpc.mocha.rtt.MainScene"
            android:label="@string/app_name"
            android:screenOrientation="reverseLandscape" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>
            <intent-filter>

                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />

                <data
                    android:host="mocha"
                    android:path="/RTT/reset"
                    android:scheme="content" />
            </intent-filter>
        </activity>
        <activity
            android:name="ihpc.mocha.rtt.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>

</manifest>

Hope this will help other developers as well !!!

Upvotes: 1

Related Questions