I had an app with several activities running perfectly until I added a new activity, which became the launch activity.
Now, the app stars in that activity but when I go to another activity it says Activity Not Found Exception even the activities are declared.
Here is my manifest, as I do not know what I am missing.
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.visualizacion.Menu"
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=".com.example.cuestionario.Page1"
android:configChanges="orientation"
android:screenOrientation="sensorLandscape"></activity>
<activity android:name=".com.example.cuestionario.Page3"
android:configChanges="orientation"
android:screenOrientation="sensorLandscape"></activity>
<activity android:name="com.example.cuestionario.Page2"
android:configChanges="orientation"
android:screenOrientation="sensorLandscape" ></activity>
<activity android:name="com.example.cuestionario.Page4"
android:configChanges="orientation"
android:screenOrientation="sensorLandscape" ></activity>
<activity android:name="com.example.cuestionario.Page5"
android:configChanges="orientation"
android:screenOrientation="sensorLandscape" ></activity>
<activity android:name="com.example.cuestionario.Page6"
android:configChanges="orientation"
android:screenOrientation="sensorLandscape" ></activity>
<activity android:name="com.example.cuestionario.Page7"
android:configChanges="orientation"
android:screenOrientation="sensorLandscape" ></activity>
<activity android:name="com.example.visualizacion.Page1C"
android:configChanges="orientation"
android:screenOrientation="sensorLandscape" ></activity>
<activity android:name="com.example.visualiacion.Page2C"
android:configChanges="orientation"
android:screenOrientation="sensorLandscape" ></activity>
</application>
When I go from Menu (Launcher Activity) to another activity it crashes with that exception.
Thank you
Check package path of your classes declared in Android Manifest and remove .(dot) from full class name. for Page1 and Page 3. i.e
android:name=".com.example.cuestionario.Page1"
and
android:name=".com.example.cuestionario.Page3"
Related
I am having 3 activities in my app and the flow is like A->B->C. When I was in activity C, I moved the app to background by pressing the home button. I brought the app to foreground again and it showed activity C as expected. When I press back key, it's closing the app and B and A are not shown.
I put the launch mode for A, C as single instance and for B, nothing is specified. I want to have one instance for all my activities. I have tried by changing the launch mode to single task(with permutation and combinations of all activities) and it didn't work.
Here is my manifest looks like for activity declaration
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
tools:ignore="GoogleAppIndexingWarning"
android:roundIcon="#mipmap/ic_myway_circular_launcher"
android:supportsRtl="true"
android:theme="#style/AppTheme.NoActionBar">
<activity
android:name="A"
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="B"
android:windowSoftInputMode="adjustPan" />
<activity
android:name="C"
android:launchMode="singleInstance"
android:windowSoftInputMode="adjustPan"/>
</application>
Can someone tell me how to maintain the back stack always even when the app is opened from background?
Thanks in advance.
you can specify the parent(previous Activity) of any activity in the Manifest
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
tools:ignore="GoogleAppIndexingWarning"
android:roundIcon="#mipmap/ic_myway_circular_launcher"
android:supportsRtl="true"
android:theme="#style/AppTheme.NoActionBar">
<activity
android:name="A"
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="B"
android:windowSoftInputMode="adjustPan" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".A"/>
</activity>
<activity
android:name="C"
android:launchMode="singleInstance"
android:windowSoftInputMode="adjustPan">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".B"/>
</activity>
</application>
After a lot of research, I found that it's the problem with the launch mode. As per Android documentation, for this mode, the system doesn't launch any other activities into the task holding the instance. The activity is always the single and only member of its task
But I wonder the issue is only coming when the app brought to foreground from background. If it is continuously running on foreground, issue is not there.
Finally, I changed it to default mode and it's working now.
I have the following manifest:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="#style/AppTheme"
<activity
android:name=".LoginActivity" android:launchMode="singleTask" 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=".MainActivity" android:screenOrientation="portrait"/>
<activity android:name=".TaskDetailActivity" android:screenOrientation="portrait"/>
<activity android:name=".ConfigurationActivity" android:screenOrientation="portrait"/>
</application>
I don't know why, if I minimize the application and then i click on application icon, the app get relaunched instead of going to the last activity.
If I use application switcher instead of application icon for opening the application, It goes back to the last activity on use, so it works as expected.
Why is this behavior? I want to open the last activity when I click on application icon not restart the whole application.
An Activity with singleTask launchMode is allowed to have only one instance in the system.
Remove android:launchMode="singleTask" for more about singletask
I need to disable splash screen auto rotate.
Need to show splash screen in portrait mode only. But app must rotate with auto rotate. How to do it in android studio ?
Add in Manifest file-->
<application
.........
>
<activity
android:name=".SplashScreenActivity"
......
android:screenOrientation="portrait"
/>
</application>
or for horizontal mode
<activity
...
...
android:screenOrientation="landscape">
In Your AndroidMainfest.xml put the screen orientation to your splash
<activity
android:name=".SplashScreenActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In the manifest, set this for your splash screen activity:
<activity android:name=".YourActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"/>
In manifest you can set the specific activity to be in portrait mode using
android:screenOrientation="portrait"
Just add below line in your manifest file, in splash activity tag
android:screenOrientation="portrait"
Something like below
<activity
android:name=".SplashActivity"
android:screenOrientation="portrait" >
Add to your splash activity declaration in the manifest this lines:
<activity
android:name="SplashActivity"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
Find relevant discussion here.
You Can do it by couple of ways
One
Inside the onCreate method of your activity
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Two
In manifest file
<activity
android:name=".NameOfYourSplashScreenActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Hope it helps
Add following code to your splash screen activity declaration in Manifest
<activity android:name=".YourActivityName"
android:label="#string/app_name"
android:configChanges = "orientation"
android:screenOrientation = "portrait">
or else add
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
to YourActivity.onCreate()
you can find a sample demo file here in github
try this in manifiest
<activity
android:name=".SplashScreenActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"/>
After testing my application on multiple device i found out that on some of them if i click application icon it shows me
WelcomeActivity instead of bringing back the application from background. I know that WelcomeActivity is LAUNCHER but on my other devices the app icon alway bring me back the background application.
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:launchMode="singleTop"
android:noHistory="true"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".WelcomeActivity"
android:screenOrientation="portrait"
android:theme="#style/Theme.AppCompat.Light.NoActionBar"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="#style/AppTheme"
android:windowSoftInputMode="adjustPan">
After WelcomeActivity i use MainActivity. and usually the app is putted to the background while that was alive.
Remove
android:launchMode="singleTop"
Because
If an instance of the activity already exists at the top of the target task, the system routes the intent to that instance through a call to its onNewIntent() method, rather than creating a new instance of the activity.
Source
I have added my third class to my package, and I want to add it to my androidmanifest.xml file. I have added the second class easily with no problem, but I'm stuck with the third one.
When do I try to add the third activity:
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.metoo.codedetective.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="com.metoo.codedetective.Etelaateomoomi">
<activity android:name=".Factoryreset">
</activity>
</activity>
</application>
</manifest>
I get The element must be a direct child of the element.
What should I do?
Please correct the code and post it.
thanks for advance
In
<activity android:name="com.metoo.codedetective.Etelaateomoomi">
<activity android:name=".Factoryreset">
</activity>
</activity>
remove <activity android:name=".Factoryreset"> </activity> because this is an activity in an activity which is not allowed.
I think you need this:
<activity android:name="com.metoo.codedetective.Etelaateomoomi.Factoryreset">
</activity>
Remove the following lines that represent an activity inside another activity.
<activity android:name=".Factoryreset">
</activity>