I've got an android application. If I go through activities(for example MainTabActivity->SearchMapActivity->ListBranchesActivity) and then hide(not close) my application, android will run the main (MainTabActivity) activity after reopen. If I press "back" button, android will show me the last activity (ListBranchesActivity). How can I make my app show the last activity after resuming? I really have no idea how to achieve that. Somebody says to add singleTask statement to manifest.
My manifest:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo"
android:largeHeap="true" >
<activity
android:name=".SearchMapActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".UpdateActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".CompanyInfoActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".FullMapActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".ListBranchesActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".ListCompaniesByBranchActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".SearchResultActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".MainTabActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Also that thing doesn't happen everytime. Sometimes it shows last activity, sometimes - main activity.
> Also that thing doesn't happen everytime. Sometimes
> it shows last activity, sometimes - main activity.
Sometime android closes your app if it needs memory. So even if you hide(not close) ...[the] application, it might have been closed anyway
Related
I am rather new to Android Studio and needed help as my app couldn't launch in the emulator despite following all the solutions I can find based on others' experiences.
I have 2 activities currently — Main and Login. I will post the AndroidManifest.xml below. Thank you all for the help and time in advanced!! (I also have this message in my event log: Can't bind to local 8700 for debugger)
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher_round"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".LoginActivity"
android:label="#string/title_activity_login">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data
android:host="ID.firebaseapp.com"
android:scheme="https" />
<category android:name="android.intent.category.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity">
</activity>
</application>
Solution:
Try this below code:
<activity
android:name=".MainActivity">
<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:host="ID.firebaseapp.com"
android:scheme="https" />
</intent-filter>
</activity>
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Try it ... Hope it helps.
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher_round"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".LoginActivity"
android:label="#string/title_activity_login">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
<data
android:host="ID.firebaseapp.com"
android:scheme="https" />
<!-- <category android:name="android.intent.category.MAIN" /> -->
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity">
</activity>
</application>
That maybe help you. :)
I am trying to launch my activity when google.com is navigated to in the browser, but it is not working. Here is my manifest:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.myapp.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:scheme="http"
android:host="google.com"/>
</intent-filter>
</activity>
</application>
Anyone see what's wrong?
So, Google Play reports that my app uses Phone calls permission. So, I had some permissions, mainly for network and internet and I've deleted all of them and I STILL HAVE phone calls permission!! Here's my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="rs.androidaplikacijekvizopstekulture"
android:versionCode="4"
android:versionName="1.1.2">
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="10" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
<activity
android:name="rs.androidaplikacijekvizopstekulture.MainActivity"
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>
<activity
android:name="rs.androidaplikacijekvizopstekulture.Menu"
android:label="#string/app_name"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="rs.androidaplikacijekvizopstekulture.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="rs.androidaplikacijekvizopstekulture.Izbor"
android:label="#string/app_name"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="rs.androidaplikacijekvizopstekulture.IZBOR" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="rs.androidaplikacijekvizopstekulture.Pravila"
android:label="#string/app_name"
android:theme="#android:style/Theme.Dialog"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="rs.androidaplikacijekvizopstekulture.PRAVILA" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="rs.androidaplikacijekvizopstekulture.DvadesetPitanja"
android:label="#string/app_name"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="rs.androidaplikacijekvizopstekulture.DVADESETPITANJA" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="rs.androidaplikacijekvizopstekulture.NeogranicenoPetGresaka"
android:label="#string/app_name"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="rs.androidaplikacijekvizopstekulture.NEOGRANICENOPETGRESAKA" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="rs.androidaplikacijekvizopstekulture.NeogranicenoTriGreske"
android:label="#string/app_name"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="rs.androidaplikacijekvizopstekulture.NEOGRANICENOTRIGRESKE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="rs.androidaplikacijekvizopstekulture.NeogranicenoJednaGreska"
android:label="#string/app_name"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="rs.androidaplikacijekvizopstekulture.NEOGRANICENOJEDNAGRESKA" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="rs.androidaplikacijekvizopstekulture.Kviz"
android:label="#string/app_name"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="rs.androidaplikacijekvizopstekulture.KVIZ" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="rs.androidaplikacijekvizopstekulture.Prefs"
android:label="#string/app_name"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="rs.androidaplikacijekvizopstekulture.PREFS" />
<category android:name="android.intent.category.DEFAULT"
/>
</intent-filter>
</activity>
<activity
android:name="rs.androidaplikacijekvizopstekulture.PogresanOdgovor"
android:label="#string/app_name"
android:theme="#android:style/Theme.Dialog"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="rs.androidaplikacijekvizopstekulture.POGRESANODGOVOR" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="rs.androidaplikacijekvizopstekulture.SwarmPopup"
android:label="#string/app_name"
android:theme="#android:style/Theme.Dialog"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="rs.androidaplikacijekvizopstekulture.SWARMPOPUP" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="rs.androidaplikacijekvizopstekulture.NetPopup"
android:label="#string/app_name"
android:theme="#android:style/Theme.Dialog"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="rs.androidaplikacijekvizopstekulture.NETPOPUP" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="rs.androidaplikacijekvizopstekulture.Rezultat"
android:label="#string/app_name"
android:theme="#android:style/Theme.Dialog"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="rs.androidaplikacijekvizopstekulture.REZULTAT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="rs.androidaplikacijekvizopstekulture.RezultatVreme"
android:label="#string/app_name"
android:theme="#android:style/Theme.Dialog"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="rs.androidaplikacijekvizopstekulture.REZULTATVREME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="rs.androidaplikacijekvizopstekulture.TacanOdgovor"
android:label="#string/app_name"
android:theme="#android:style/Theme.Dialog"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="rs.androidaplikacijekvizopstekulture.TACANODGOVOR" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
So, apsolutely no permissions in my manifest file, and I still get the Phone calls permission. I DON'T GET IT!
The compiler automatically adds this permission for compatibility reasons if your app use a library designed to run on Android 1.5 or below (because this permission was introduced in Android 1.6).
I guess it's caused by the AdMob library, which still supports Android 1.5.
I can't find any problem but it keep giving me the error "No Launcher activity found!" and "The launch will only sync the application package on the device!"
can anyone solve this problem???
This is my Maniest
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.saikoro.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.saikoro.StartUp"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.saikoro.StartUp" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
The <activity> element of the activity you want to launch through the icon on the app list must contain both of the following parts of the intent-filter:
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
Your current manifest has an activity with category LAUNCHER and action MAIN, but in different activities. The one with the icon in the app list must have them both.
Change
<action android:name="com.example.saikoro.StartUp" />
with
<action android:name="android.intent.action.MAIN" />
I am making a simple Android Application, which consists of only two activities, .Password and .Adder
<activity
android:name=".Adder"
android:label="#string/title_activity_adder" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Password"
android:label="#string/title_activity_adder" >
<intent-filter>
<action android:name="android.intent.action.PASSWORD" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The .Password activity is set as the LAUNCHER but when I run it, the .Adder Activity shows us instead.
I have the .xml and .java file for both the activity properly connected by setContentView() and Eclipse is not reporting any kind of error in any file at all.
The Password Activity checks for the correct password and switches control to the Adder Activity:
Intent openStartingPoint = new Intent("com.example.pointsadder.MAIN");
startActivity(openStartingPoint);
You don t have to write intent filter to each activity. Correct xml:
<activity
android:name=".Adder"
android:label="#string/title_activity_adder" >
</activity>
<activity
android:name=".Password"
android:label="#string/title_activity_adder" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Change this:
<activity
android:name=".Password"
android:label="#string/title_activity_adder" >
<intent-filter>
<action android:name="android.intent.action.PASSWORD" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
to this:
<activity
android:name=".Password"
android:label="#string/title_activity_adder" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
And modify this as shown:
<activity
android:name=".Adder"
android:label="#string/title_activity_adder" >
</activity>
Refer to this link: http://developer.android.com/guide/topics/manifest/manifest-intro.html#iconlabel for more details.