Pratik Popat
Pratik Popat

Reputation: 2999

How to Launch android apps within my application in Android?

In my application there is tab layout. and two tabs.

Thanks in advance

Upvotes: 12

Views: 2406

Answers (3)

TryTryAgain
TryTryAgain

Reputation: 7820

I may have misunderstood this, but unless you have created explicit intents (worked with the other app developer or created the other app you wish to embed) this will not be possible.

Each Android app runs in a sandbox: http://developer.android.com/guide/topics/security/security.html

Particularly:

Because Android sandboxes applications from each other, applications must explicitly share resources and data. They do this by declaring the permissions they need for additional capabilities not provided by the basic sandbox. Applications statically declare the permissions they require, and the Android system prompts the user for consent at the time the application is installed. Android has no mechanism for granting permissions dynamically (at run-time) because it complicates the user experience to the detriment of security.

Therefore this would not be possible. It seems misguided or malicious to begin with, but I would seriously reconsider your approach and rethink the benefits weighed against the unlikelihood of even being able to achieve what you ask.

Upvotes: 12

ChrLipp
ChrLipp

Reputation: 15668

In my opinion this is not possible.

You can only display your own activies inside a TabHost. For external activities you would need an implicit intent, but TabHost does not support this: Embed external Intent in main Activity

Therefor you display the data from a foreign application in your own activity. Do do this, you query the content provider the other application provides (see http://developer.android.com/guide/topics/providers/content-providers.html) in your list activity (see a complete example at http://developer.android.com/reference/android/app/ListActivity.html) and inclucde this ListActivity in your TabHost.

Upvotes: 1

since2006
since2006

Reputation: 226

read doc (intent section), some example:

public class MyTab extends TabActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        final TabHost tabHost = getTabHost();

        Intent taskIntent = new Intent(this, Public.class);
        taskIntent.putExtra(Intent.ACTION_VIEW, "public");

        TabHost.TabSpec tsValid = tabHost.newTabSpec("public");
        tsValid.setIndicator(getText(R.string.tab_title_public));
        tsValid.setContent(taskIntent);

        tabHost.addTab(tsValid);

        Intent annIntent = new Intent(this, Private.class);
        annIntent.putExtra(Intent.ACTION_VIEW, "private");

        TabHost.TabSpec tsGenerate = tabHost.newTabSpec("private");
        tsGenerate.setIndicator(getText(R.string.tab_title_private));
        tsGenerate.setContent(annIntent);

        tabHost.addTab(tsGenerate);
    }

}

Upvotes: 1

Related Questions