0

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

Community
  • 1
  • 1
kAnNaN
  • 3,669
  • 4
  • 28
  • 39
  • 1
    You can't embed activities from other apps in your own application. – user Mar 27 '13 at 07:23
  • They have done it in the ref link that i have posted. I tried it with a button click which worked but unable to implement it in TabActivity. – kAnNaN Mar 27 '13 at 07:32
  • It's not the same thing. You can use an `Intent` to start a new `Activity` from another app, but in your case using `setContent()` with an `Intent` is actually building the content of that tab with the activity pointed by the `Intent`. So basically the started Activity will be embedded in the `TabActivity`(which you shouldn't use in the first place as it's deprecated) which is not allowed in Android(resulting in that SecurityException). – user Mar 27 '13 at 07:36
  • Oh Ok .So are there any alternatives ? – kAnNaN Mar 27 '13 at 07:46
  • To embed an Activity, no. So you'll need to rethink your current logic. – user Mar 27 '13 at 07:49

2 Answers2

3

It is not possible to show another app's Activities in your own app like an iframe of sorts for security reasons.

You can however launch the Activity normally and pass control to it.

AndroidBot
  • 201
  • 2
  • 4
2

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

stinepike
  • 54,068
  • 14
  • 92
  • 112