Search code examples
androidandroid-intenttabsandroid-activityintentfilter

Calling install application activity from an other applications tabbed activity?


In reference with the answer to the link below.

Android : Call activity of another application

I tried it as firstTabSpec.setIndicator("Second Tab Name").setContent(new Intent("com.company.package.FOO"));

but i'm getting a

java.lang.SecurityException: Requesting code from com.company.package (with uid 10036) to be run in process com.example.test (with uid 10037)

Where com.example.test is the package calling the installed package "com.company.package.FOO"

com.company.package Manifest

<activity
        android:name="com.company.package.Login"
        android:label="@string/app_name"
        android:windowSoftInputMode="adjustResize|stateVisible" >
        <intent-filter>
            <action android:name="com.company.package.FOO" />

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

com.example.test Manifest

 <activity
        android:name="com.example.test.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

Please let me know if u need more details.

Thanks :)


Solution

  • you can send a intent message to open another application activity but you can not use another application's activity in your tab. At best you can do one thing. Somehow detect when the tab where you wanted to show the other application's tab is switched and from there send the intent to start that application. By doing so you will not able to show that application's activity within your tab but you can start the application like a different activity. To do this you do any of the following

    Option 1:

    say in tab A you want to start other application. In tab A set an activity with blank layout. And in the onCreate method of that activity start the other application. But here is a problem. When the other application is finished there will be a blank screen. In my cases to fix this I just switched the tab to the main (other one) tab when the other application is closed.

    Option 2:

    you can detect when a tab is changed by using TabHost.OnTabChangeListener listener. And then you can do the same things.

    Option 3:

    or you can do the same thing by detecting the tab button click.

    Anyway all of the above 3 options are just the variation of same option. Although it is not a good solution but I can not see any better solution at this moment. Hope it will work for you. Thanks