Launch activity module from main App Android - android

I'm trying to launch an Activity on a module I imported from my main app.
Nothing is happening. No crash and no launch. Here is my code on my main app:
Intent moduleActivity = new Intent("com.service.ModuleActivity");
startActivity(moduleActivity);
Here is the module manifest :
<application
android:allowBackup="true"
android:supportsRtl="true"
android:largeHeap="true"
android:persistent="true" >
<activity android:name="com.service.ModuleActivity"
android:screenOrientation="landscape"
android:launchMode="singleTask">
<intent-filter>
<action android:name="com.service.ModuleActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
I have no crash and on debug the Intent moduleActivity is not null
What did I miss ?

Finally I resolved it..
Intent moduleActivity = new Intent("com.service.ModuleActivity");
moduleActivity .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //by adding this line
startActivity(moduleActivity);
Thanks all

Related

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myapp/androidx.fragment.app.FragmentActivity}

I am using BottomNavigation Menu in my app which has 4 submenus: Address, Dashboard, Home, Notifications.
When I want to startActivity from HomeFragment to Dashboard Fragment it gives me error that I have depicted below.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.karatasyazilim.su, PID: 21216
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.karatasyazilim.su/androidx.fragment.app.FragmentActivity}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2069)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1717)
at android.app.Activity.startActivityForResult(Activity.java:5252)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:675)
at androidx.core.app.ActivityCompat.startActivityForResult(ActivityCompat.java:234)
at androidx.fragment.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:790)
at androidx.fragment.app.FragmentActivity$HostCallbacks.onStartActivityFromFragment(FragmentActivity.java:932)
at androidx.fragment.app.Fragment.startActivity(Fragment.java:1257)
at androidx.fragment.app.Fragment.startActivity(Fragment.java:1245)
at com.karatasyazilim.su.ui.home.HomeFragment$5.onClick(HomeFragment.java:333)
at android.view.View.performClick(View.java:7869)
at android.widget.TextView.performClick(TextView.java:14958)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:992)
at android.view.View.performClickInternal(View.java:7838)
at android.view.View.access$3600(View.java:886)
at android.view.View$PerformClick.run(View.java:29362)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8016)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1087)
My manifest is :
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.Su">
<activity android:name=".CreateAddress"></activity>
<activity android:name=".PhoneActivation" />
<activity
android:name=".Genel"
android:label="#string/title_activity_genel" />
<activity android:name=".SignUp" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="#string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
</application>
And here is my activiy code.
Intent kalimera = new Intent(getActivity(), FragmentActivity.class);
startActivity(kalimera);
What am I doing wrong?
You're trying to start the androidx FragmentActivity class directly. This is a parent class that you should subclass to create your own Activity.
Instead, make sure that you're using the name of the Activity you want to launch instead:
Intent intent = new Intent(getActivity(), NameOfTheActivityThatYouWantToLaunch.class);
startActivity(intent);
Alternately, if you aren't trying to launch an Activity and just got this code from somewhere, simply remove those lines.
If you're trying to launch a Fragment instead, take a look at How to start Fragment from an Activity

android sdk product flavors - activity not found when I start a new activity using intent

I have a working app to which I have added 2 product flavors. This app has a menu on the first screen which allows the user to choose the next activity, which I load with an intent.
Here is AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name="com.alpha.aloedu.MainActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.alpha.aloedu.guideddrawing.GuidedLetterDrawingActivity"
android:label="Guided Letter Drawing"
android:screenOrientation="portrait" />
<activity
android:name="com.alpha.aloedu.buildvocabulary.BuildVocabularyActivity"
android:label="Image Plus Word"
android:screenOrientation="portrait" />
<activity
android:name="com.alpha.aloedu.findthepicture.FindThePictureActivity"
android:label="Find the Picture"
android:screenOrientation="portrait" />
<activity
android:name="com.alpha.aloedu.findtheletter.FindTheLetterActivity"
android:label="Find the Letter"
android:screenOrientation="portrait" />
<activity
android:name="com.alpha.aloedu.fillintheletter.FillInTheLetterActivity"
android:label="Find the Letter"
android:screenOrientation="portrait" />
<activity
android:name="com.alpha.aloedu.EndActivity"
android:label="End Activity"
android:screenOrientation="portrait" />
<activity
android:name="com.alpha.aloedu.AdminActivity"
android:label="Admin Activity"
android:theme="#style/AppTheme.NoActionBar"
android:screenOrientation="portrait"
/>
</application>
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:requiresSmallestWidthDp="480"
android:resizeable="false"
android:smallScreens="false"
android:xlargeScreens="true" />
Here is the relevant portion of the gradle file:
productFlavors {
de {
applicationIdSuffix ".de"
versionName "1.1de"
}
fr {
applicationIdSuffix ".fr"
versionName "1.1fr"
}
}
Here is the source tree:
Here is the code where I load the next activity:
Intent intent = new Intent();
intent.setClassName("com.alpha.aloedu", newClassName);
currentActivity.startActivity(intent);
currentActivity.finish();
I have set a breakpoint on the second line and "newClassName" has the correct value. However, when I run the "deDebug" variant, I get an error on the third line:
android.content.ActivityNotFoundException:
Unable to find explicit activity class
{com.alpha.aloedu/com.alpha.aloedu.guideddrawing.GuidedLetterDrawingActivity};
have you declared this activity in your AndroidManifest.xml?
The class GuidedLetterDrawingActivity does exist in the main source tree, and also in AndroidManifest.xml.
Thank you for any help you can provide.
You must declare activities of each flavor in its manifest file
...\src\ de \AndroidManifest.xml
...\src\ fr \AndroidManifest.xml
Declare each new activity in manifest. Even if you change the name you have to modify the manifest file.
<application
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".new_Activity"
android:label="#string/app_name"/>
<activity
android:name=".new_Activity2"
android:label="#string/app_name"/>
</application>
This has to be declared in main java file
Intent intent = new Intent(MainActivity.this, newActivity.class);
startActivity(intent);
Intent intent1 = new Intent(MainActivity.this, newActivity2.class);
startActivity(intent1);
execute the intent block of code as per your requirement in the same or different functions.

I haveSecurityException: Permission Denial error

I am getting the following error:
ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.optionpricing/.optionListNew } from null (pid=1160, uid=2000) requires null
I am new to programming in Android and I could not make sense of the other postings related to my problem. I wonder if there is an issue with the optionListNew class? Can someone lend a hand so I can move on to completing my app. Also, the app runs in my virtual device, and I only get this error when I try to test it on my actual phone.
Any ideas are appreciated. Below is the manifest file.
<?xml version="1.0" encoding="UTF-8"?>
<manifest android:versionCode="1" android:versionName="1.0"
package="com.optionpricing" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="8"/>
<application android:icon="#drawable/icon"
android:label="#string/app_name"
android:debuggable="true">
<activity android:name=".optionListNew">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".OptionPricing"/>
<activity android:name=".optionListNew"/>
<activity android:name=".futureOptionActivity"/>
<activity android:name=".currencyOptionActivity"/>
<activity android:name=".gapOptionActivity"/>
<activity android:name=".gapOptionList01"/>
<activity android:name=".barrierSingleUpInActivity"/>
<activity android:name=".testActivity"/>
<activity android:name=".barrierlistview"/>
<activity android:name=".barrierSingleDownInActivity"/>
</application>
</manifest>
You added "optionListNew" activity twice in the manifest file.. remove below activity by deleting this line
<activity android:name=".optionListNew"/>
Your Manifest.xml code will become
<?xml version="1.0" encoding="UTF-8"?>
<manifest android:versionCode="1" android:versionName="1.0"
package="com.optionpricing" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="8"/>
<application android:icon="#drawable/icon"
android:label="#string/app_name"
android:debuggable="true">
<activity android:name=".optionListNew">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".OptionPricing"/>
<activity android:name=".futureOptionActivity"/>
<activity android:name=".currencyOptionActivity"/>
<activity android:name=".gapOptionActivity"/>
<activity android:name=".gapOptionList01"/>
<activity android:name=".barrierSingleUpInActivity"/>
<activity android:name=".testActivity"/>
<activity android:name=".barrierlistview"/>
<activity android:name=".barrierSingleDownInActivity"/>
</application>
</manifest>
optionListNew is present twice in the manifest. Remove the second.

ActivityNotFoundException but already declared in the Manifest

HY!
I always get the ActivityNotFound Error, but i already have my Activity declared in the Manifest.
Whats wrong?
Error:
10-17 20:28:24.881: ERROR/AndroidRuntime(2141): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.korn.supplierplan/com.korn.supplierplan.view.LVEntries}; have you declared this activity in your AndroidManifest.xml?
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.korn.supplierplan"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name = "android.permission.INTERNET"> </uses-permission>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".view.Login"
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=".view.LVEntries"></activity>
</application>
</manifest>
Calling:
Intent i = new Intent (Login.this,LVEntries.class);
i.putExtra("JSON", array.toString());
startActivity(i);
The problem is in how you are naming the Activities in you Manifest file.
I'm guessing your class files are named Login.java not view.Login.java, am I right? If so change this:
<activity android:name=".view.Login" android:label="#string/app_name">
To This
<activity android:name="Login" android:label="#string/app_name">
Do the same for LVEntries
If they are named like view.Login.java then remove the prepended view. in the name.

changing launching activity

i want to change my launching activity.for the moment my manifest is this:
<application android:icon="#drawable/iconbj" android:label="#string/app_name"
android:debuggable="true">
<activity android:name=".Main" android:label="#string/app_name" android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="DemoPlayActivity" android:name="DemoPlayActivity" android:screenOrientation="landscape"></activity>
</application>
now I have created another activity which is a splash screen and i want to launch this instead of Main so I tried this way:
<application android:icon="#drawable/iconbj" android:label="#string/app_name"
android:debuggable="true">
<activity android:name=".Splash" android:label="#string/app_name"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="Main" android:label="Main"
android:screenOrientation="landscape">
</activity>
<activity android:label="DemoPlayActivity" android:name="DemoPlayActivity"
android:screenOrientation="landscape"></activity>
</application>
but i get thisproblem with permission:
[2011-03-31 16:32:44 - BlackJackNuovo]
ActivityManager:
java.lang.SecurityException:
Permission Denial: starting Intent {
act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER]
flg=0x10000000
cmp=com.phinet.android.blackjack/.Main
} from null (pid=-1, uid=-1) requires
null.
please help me :)
Update
NO WAY. I did this way:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.phinet.android.blackjack" android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<application android:icon="#drawable/iconbj" android:label="#string/app_name"
android:debuggable="true">
<activity android:name="com.phinet.android.blackjack.Splash" android:label="Splash"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.phinet.android.blackjack.Main" android:label="Main"
android:screenOrientation="landscape">
</activity>
<activity android:label="com.phinet.android.blackjack.DemoPlayActivity" android:name="DemoPlayActivity"
android:screenOrientation="landscape"></activity>
</application>
</manifest>
but it seems to lunch always the Main activity,this is the concole log:
[2011-04-01 10:57:10 - BlackJackNuovo] Uploading BlackJackNuovo.apk onto device '9000d365e767'
[2011-04-01 10:57:16 - BlackJackNuovo] Installing BlackJackNuovo.apk...
[2011-04-01 10:57:32 - BlackJackNuovo] Success!
[2011-04-01 10:57:32 - BlackJackNuovo] Starting activity com.phinet.android.blackjack.Main on device 9000d365e767
[2011-04-01 10:57:32 - BlackJackNuovo] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.phinet.android.blackjack/.Main }
[2011-04-01 10:57:35 - BlackJackNuovo] ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.phinet.android.blackjack/.Main } from null (pid=-1, uid=-1) requires null
WHY?
<activity android:name="Main" android:label="Main"
android:screenOrientation="landscape">
</activity>
<activity android:label="DemoPlayActivity" android:name="DemoPlayActivity"
android:screenOrientation="landscape"></activity>
Should still have the leading .
<activity android:name=".Main" android:label="Main" android:screenOrientation="landscape">
</activity>
<activity android:label=".DemoPlayActivity" android:name="DemoPlayActivity"android:screenOrientation="landscape">
</activity>
This is stating it has a relative path to your Classes. You could make absolute references if you wished, i.e. "com.your.app.Main"

Categories

Resources