0

this is my first question I have searched for any launching activity questions and none worked for me(android 4.0.4), but works for others.

I have already a list of every installed activity in the phone but I cannot launch them

ComponentName cm= new ComponentName("com.sonyericsson.extras.liveview","com.sonyericsson.extras.liveview.LAUNCH");
intent.setComponent(cm);
startActivity(intent);

that code is failing for me "unable to find explicit activity...", that constant strings may vary depending on selection, any way this doesn't work, neither does other solutions found here. Logcat says that maybe I didn't declare the activity in the manifest.xml but of course I didn't, I want to start ANY activity just as ADW launcher does, also tried to use code from ADW source but didn't work. Thanks in advance

  • There is no problem with your code if it runs on a Sony Ericsson phone but if you try to run it on a Motorola or a HTC phone you might see the problems of calling the package. – Sana Jun 15 '12 at 04:06
  • Thanks sara, but that string is constant by now, but it has to vary, any way its not working on my SE phone, the activity is installed – aguilar8325 Jun 15 '12 at 05:11
  • So lets say when you open the activity LAUNCH does it have the package as com.sonyericsson.extras.liveview – Sana Jun 15 '12 at 05:18
  • Yes, and will not be registered on my manifest because that strings will vary – aguilar8325 Jun 15 '12 at 05:34

2 Answers2

1

Try using this instead

String app = "com.sonyericsson.extras/liveview";
Intent intent = new Intent(Intent.ACTION_MAIN);             
intent.setComponent(ComponentName.unflattenFromString(app));             
intent.addCategory(Intent.CATEGORY_LAUNCHER);             
startActivity(intent); 
FabianCook
  • 20,269
  • 16
  • 67
  • 115
  • No luck, logcat: android.content.ActivityNotFoundExceptio: Unable to find explicit class{com.sonyericsson.extras/liveview}; have you declared activity in your AndroidManifest.xml? my manifest doesn't have it because it will vary, in future uses I will only use an ActivityInfo from a vector of all installed activities, so I will get activity and package strings from there. I know it's possible because every home or launcher app does this. ADW code seems complicated – aguilar8325 Jun 15 '12 at 05:09
0

Try

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName("com.sonyericsson.extras.liveview", "com.sonyericsson.extras.liveview.LAUNCH");
startActivity(intent);

I believe the name of the package is ok but the activity name being all CAPS hurts me :|, but try and let me know if it works for you.

Sana
  • 9,895
  • 15
  • 59
  • 87
  • Thanks a lot! this is how I made it: `Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName(activinfos.get(position).packageName, activinfos.get(position).name); startActivity(intent);` – aguilar8325 Jun 15 '12 at 05:54