Intent intent = new Intent();
intent.setClassName("another_app_package_name","another_app_package_name.class_name_in_that_package");
startActivity(intent);
getting ActivityNotFoundException ?
How to solve this problem? This problem posted earlier as well but no solution.I manifest file of application whose activity to be called i have used intent filter as well.
Activity to be called by some other application's activity
<activity
android:name="com.example.custompermission.PrivActivity">
android:permission="abc.permission.STARTMYACTIVITY">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
Check this
Intent intent = new Intent();
intent.setClassName(another_app_package_name.this,another_app_package_name.class_name_in_that_package.class);
startActivity(intent);
and in manifest.xml add this
<activity android:name="another_app_package_name.class_name_in_that__package" android:configChanges="orientation|keyboardHidden"></activity>
In manifest file you do like this:
<activity android:name="another_app_package_name.class_name_in_that__package"></activity>
you should add the activity in manifest file, which you are tried to called from first activity.
you need to add both the activities in manifest file:
for ex:
Intent intent = new Intent (HomePage.this, Second.class);
startActivity(intent);
in manifest: <application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".HomePage"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name =".Second"></activity>
</application>
Once, clean the project and run.
Related
I'm trying to start an activity in another package, I already saw a lot of answers on the topic, but the answers I found don't seem to work for me.
Here how I call the other activity:
Intent intent = new Intent();
intent.setClassName("com.packageroot.package2", "com.packageroot.package2.MainActivity");
context.startActivity(intent);
And here my Manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.packageroot" >
<application
<activity
android:name=".package1.MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.packageroot.package2.MainActivity"
android:label="#string/title_activity_main"
android:theme="#style/AppTheme"
android:parentActivityName=".package1.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".package1.MainActivity"/>
</activity>
And I still get this error:
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.packageroot.package2/com.packageroot.package2.MainActivity}; have you declared this activity in your manifest?
What I don't get is that the path indicated is the error is exactly the name of the activity...
Thanks a lot in advance.
You could try adding the package to the build.gradle file under dependencies:
dependencies {
compile 'com.packageroot.package2'
}
change this line:
intent.setClassName("com.packageroot.package2", "com.packageroot.package2.MainActivity");
to
intent.setClassName("com.packageroot", "com.packageroot.package2.MainActivity");
The first parameter is "package name".
http://developer.android.com/reference/android/content/Intent.html#setClassName%28java.lang.String,%20java.lang.String%29
If your intent go through packages,this is what you should do.
In your Manifest
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:exported="true">//got to declare this
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="YOUR ACTION NAME" />
//At least one category,use DEFAULT if you don't have one
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
And in your Activity
Intent intent = new Intent();
intent.setAction(YOUR ACTION NAME);
intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivity(intent);
Best Solution Work for me is controlling the back Button
#Override
public void onBackPressed() {
Intent intent = new Intent(CurrentActivity.this, SecoundActivity.class);
startActivity(intent);
finish();
}
I would like to launch, from my app, two specific activities A_Activity and B_Activity from apps Aapp and Bapp
I inserted two buttons and in the two OnClickListener I wrote
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction("com.Acompany.Aapp.A_Activity");
ctx.startActivity(intent);
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction("com.Bcompany.Bapp.B_Activity");
ctx.startActivity(intent);
Moreover I added to AndroidManifest.xml the following lines
<activity
android:name="com.Acompany.Aapp.A_Activity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.Acompany.Aapp.A_Activity" />
</intent-filter>
</activity>
<activity
android:name="com.Bcompany.Bapp.B_Activity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.Bcompany.Bapp.B_Activity" />
</intent-filter>
</activity>
But my app crashes and in the logcat I read "No Activity found to handle Intent"
Where is my mistake?
EDIT: More precisely the two activities are not in my own app
More precisely the two activities are not in my own app
You should investigate target app's manifest file first, to check if these activities are available to others by being exported or offering publicly accessible intent filters. It looks you may simply be not allowed to do what you attempt to.
Try like this. For your home activity(first launch activity) do like this in your manifest file.xml
<activity
android:name="com.Acompany.LaunchHomeActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.Acompany.LaunchHomeActivity" />
</intent-filter>
</activity>
<activity android:name="com.Acompany.Aapp.A_Activity">
</activity>
<activity android:name="com.Bcompany.Bapp.B_Activity">
</activity>
don't include <intent-filter> to all activities
Intent intent = new Intent(myFirstClass.this, MySecondClassA.class);
startActivity(intent);
Class B
Intent intent = new Intent(myFirstClass.this, MySecondClassB.class);
startActivity(intent);
Good afternoon,
I have an activity that calls another. The code is as follows:
Intent i = new Intent(getApplicationContext(),Menu.class);
startActivity(i);
When I run the application get the following error:
android.content.ActivityNotFoundException: Unable to find explicit activity class {proyecto.uvigo/android.view.Menu}; have you declared this activity in your AndroidManifest.xml?
I do not understand what is wrong because I have already stated, the Activity Menu on the AndroidManifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="proyecto.uvigo"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".Inicio"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-permission android:name="android.permission.INTERNET" />
<activity android:name=".Login"></activity>
<activity android:name=".Menu"></activity>
<activity android:name=".RecuperarPass"></activity>
<activity android:name=".Auxiliar"></activity>
<activity android:name=".MiPerfil"></activity>
<activity android:name=".CambiarPass"></activity>
</application>
Thanks!
It's because your code is using android.view.Menu as an Activity instead of your Menu class. Try this:
Intent i = new Intent(getApplicationContext(), proyecto.uvigo.Menu.class);
startActivity(i);
Alternately, you could rename your Menu class to something like UvigoMenu or UvigoMenuActivity in your class and in your manifest, just to avoid confusion like this.
I am not sure but there is something wrong with Unable to find explicit activity class {proyecto.uvigo/android.view.Menu};. Why android.view.Menu?. Please, check if import android.view.Menu class. If yes, use this
Intent i = new Intent(getApplicationContext(), proyecto.uvigo.Menu.class);
or import proyecto.uvigo.Menu instead of android.view.Menu.
start Menu activity as:
Intent i = new Intent(getApplicationContext(), proyecto.uvigo.Menu.class);
startActivity(i);
or
Intent i= new Intent();
i.setComponent(new ComponentName("proyecto.uvigo", "proyecto.uvigo.Menu"));
startActivity(i);
change
<activity android:name=".Menu"></activity>
to
<activity android:name=".Menu">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
I keep getting "ActivityNotFoundException: Unable to find explicit activity class ... " when using Eclipse's emulator to call the activity of another application from an application. Perhaps the problem maybe related to I am not able to download to/find both applications at the same time when I click on "Manage Applications" in Settings. This is the first project I need to call the activity of another application. But I am not sure the code is correct either. Please help me determine if there are errors in the code snippets I present below. It is hinted that I can set the action field of the intent to achieve the objective but have not found learning material for this. I learned about using the setComponent method in the calling app and to add android:export to the called activity's AndroidManifest.xml. Thanks in advance!
Calling app's relevant source code:
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.MyPackage", om.MyPackage.Activity1));
startActivity(intent);
Calling app's relevant AndroidManifest.xml :
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".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>
<activity android:name=".Activity1">
<intent-filter>
<action android:name="com.MyPackage.Activity1" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
Relevant code of AndroidManifest.xml of the activity of another application
<activity android:name=".Activity1" android:exported = "true">
<intent-filter>
<action android:name="com.MyPackage.Activity1" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Firstly point out that you're trying to start Activity in Application2 from Activity in Application1
You have to give them separate namespaces
both applications now have com.MyPackage.* prefix
OR use names Activity1 and Activity2
So you will have
com.MyPackage1.Activity1
// and
com.MyPackage2.Activity1
Then you can use this code, to start Activity1 in MyPackage2 from MyPackage1.
// in file com.MyPackage1.Activity1
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.MyPackage2", "com.MyPackage2.Activity1"));
startActivity(intent);
And your AndroidManifest.xml files should look like this:
first
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name="com.MyPackage1.Activity1"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
second
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name="com.MyPackage2.Activity1"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
see related SO question:
How to start activity in another application?
image of the offending pointer:
http://i842.photobucket.com/albums/zz347/oxygen_addict/bugs/device.png
the problem is that this pointer shows up whenever I transition from one activity to another.
code of the intent's:
final Intent intent = new Intent(ActivityTwo.this, test.app.com.ActivityOne.class);
startActivity(intent);
final Intent intent = new Intent(ActivityOne.this, test.app.com.ActivityTwo.class);
startActivity(intent);
Manifest:
<!-- LAUNCH ACTIVITY -->
<activity android:name=".ActivityOne"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- SUB-ACTIVITIES -->
<activity android:name=".ActivityTwo"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:noHistory="true"
android:theme="#android:style/Theme.NoTitleBar" />
Note:
within onCreate() of each activity I am using
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
How can I get rid of the pointer ?
FYI: the OS has to be rebuilt to remove the pointer.
Would have been awesome to have an Application-level API available to control it....