• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

App within an app

Philleh

Lurker
Oct 16, 2010
6
0
Hi guys, building a program with a number of menu options. One of them I want to launch another app. I tried using intents code but seem to keep getting an error. Heres my code.

package com.androidbook.prototype;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class FYPMenuActivity extends FYPActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
ListView menuList = (ListView) findViewById(R.id.ListView_Menu);
String[] items = { getResources().getString(R.string.menu_item_setlaunch),
getResources().getString(R.string.menu_item_scweb),
getResources().getString(R.string.menu_item_settings),
getResources().getString(R.string.menu_item_help) };
ArrayAdapter<String> adapt = new ArrayAdapter<String>(this, R.layout.menu_item, items);
menuList.setAdapter(adapt);
menuList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View itemClicked, int position, long id) {
TextView textView = (TextView) itemClicked;
String strText = textView.getText().toString();
if (strText.equalsIgnoreCase(getResources().getString(R.string.menu_item_setlaunch))) {
// Launch astro file manager example problems *******
startActivity(new Intent(FYPMenuActivity.this, FYPSetupActivity.class));
// Intent i = new Intent(Intent.ACTION_MAIN);
//i.addCategory(Intent.CATEGORY_LAUNCHER);
//i.setPackage("com.metego.astro");
//startActivity(i);

} else if (strText.equalsIgnoreCase(getResources().getString(R.string.menu_item_help))) {
// Launch the Help Activity
startActivity(new Intent(FYPMenuActivity.this, FYPHelpActivity.class));

EDIT:

Without the commented code, [the intent stuff after * startActivity(new Intent(FYPMenuActivity.this, FYPSetupActivity.class));] the app (Im following a book tutorial) brings you to a plain default text xml screen. I want it to launch an app thats installed on the phone. There's other menu options too, but I want the first option to launch astro file manager - (or any app really, for the moment - just to get it working!)

Can anyone advise?

Thanks!
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones