user1426956
user1426956

Reputation: 123

Android phone application intent

I want to launch the phone application on the phone as an intent

I am using this code

startActivity(getPackageManager().getLaunchIntentForPackage("com.android.phone"));

but the function throws an nullpointer excaption so there is no launchable itent but how can i launch it to make the user watch the telephonylogs

Upvotes: 3

Views: 3362

Answers (4)

j2emanue
j2emanue

Reputation: 62519

You need permissions for certain ones ...better off doing

  Intent intent = new Intent(Intent.ACTION_MAIN, null);
 intent.addCategory(Intent.CATEGORY_LAUNCHER);
     List<ResolveInfo> packs = mContext.getPackageManager().queryIntentActivities(intent,     PackageManager.PERMISSION_GRANTED);

and then you got the list of things you have permission for and then sort through this to launch.

Upvotes: 2

prowebphoneapp
prowebphoneapp

Reputation: 87

I solved this problem previously, so here it is:

Intent i = new Intent();
PackageManager manager = getPackageManager();
i = manager.getLaunchIntentForPackage("com.android.htcdialer");
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);

Upvotes: -3

user1426956
user1426956

Reputation: 123

I managed to answer my question thanks for your answers the didn't exactly met the thing I wanted but on base of tham I figured it out

I just had to call

Intent intent = new Intent(Intent.ACTION_DIAL);

startActivity(intent);

to open only the phone application

Upvotes: 2

Sana
Sana

Reputation: 9915

I have used the below code to dial a phone number with an intent, it might work for you.

String uri = "tel:" + phoneNumber.trim() ;
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse(uri));
startActivity(intent);

Upvotes: 0

Related Questions