I am developing an Android app. At first everything was going smooth, but after some time, the app started to disappear (more accurate not appear) after a successful installation on a real android device. After installing it, the open button is deactivated (I can only click done) and I cannot find it on the menu, but checking with root uninstaller, it appears that the app is really installed.
On the emulator, it installs ok but the installed app doesn't show the correct icon, while prior to this error it wasn't doing so.
I forced the removal of some permissions # Manifest, because I only need (and the app was running with it only) internet access (web view). I tried removing that but it is just the same.
This change came when I introduced a splash screen which loads after the webview if it's the first time ==> MainActivity: If it's first time { setContentView with splash layout. Eventually, after the 3 slides, button onClick which changes to webview activity (class)(1) } else { setContentView with webview layout(2) }
(1) and (2) perform the same tasks, (2) inside a method in MainActivity and (1) in the onCreate of the WebView class.
I know for a fact that it is a better way to do this. Any help on how to do perform this task in a better way appreciated, and also how to get rid of the "installed but invisible" thing.
In your manifest ensure that your intent filter has the category <category android:name="android.intent.category.LAUNCHER" />
<activity
android:name=".activity.SpashScreenActivity"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:windowSoftInputMode="stateHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Related
i am using one app, for example chrome with some confidential information and i am switching it to background & i am trying to kill the app.
i uploaded the example image when trying to kill the app. even the session the expired it won't close the information in the killing stage when app comes foreground then only it closes the information. i want the info should be closed or hided when it goes background (In killing stage).
i searched in google i am not getting anything related to this and i don't know whether my search phrase is correct. can anyone pleas help me.
I think ur asking this:
Just add this in manifest file:
android:excludeFromRecents="true"
Example:
<activity
android:name=".MainActivity"
android:excludeFromRecents="true"
android:taskAffinity=".OnInviteActivity"
android:noHistory="true"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
then your app will not show in background or recent app or in menu like that
UPDATE:
for ur app name only u need to add this in Main Activity:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
I am experiencing a little pain on Android. I have two activities, one is a Splash Screen, launched when you click on the app icon, and an other one which can wake up when a specific event occurred (a NFC event, but it is not the problem).
There is the declaration in the manifest :
<activity android:label="#string/general.appName" android:name=".activity.SplashActivity" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:excludeFromRecents="true" android:label="#string/general.appName" android:name=".EventReceiver" android:noHistory="true" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.nfc.action.TRANSACTION_DETECTED">
</action>
<category android:name="android.intent.category.DEFAULT">
</category>
<data android:host="secure" android:path="/aXXXXX" android:port="0" android:scheme="nfc"/>
</intent-filter>
</activity>
All works fine, it means that the EventReceiver is launched when it received a specific event, the Splash Screen is functional etc...
But, when the application is launched by an event, so it is the EventReceiver which is launched first. If I pause the app by clicking on the home button of the phone, and by long clicking on it again, it makes appear the multitask table, with all the recent opened apps. There, is I click on my application, it resumed the application on the EventReceiver, just like if an event had occurred. So do you know a way to resume an application on one selected activity only (in my case the SplashScreen).
Or do you know a way to recognize that the application was resumed by a multitask function ? (I could open the good activity at the onCreate of my EventReceiver too if I get this information).
For the moment, the only solution I found is to put a android:excludeFromRecents="true" flag on my EventReceiver activity. This will result that the application will not appear in the multitask table if the application was launched by an event. But this is a little bit tricky and I do not like that very much.
Do you have any ideas ?
Thank you very much beforehand for your answers ! (and sorry for my scholar English ^^)
If you really have to detect when the application is lauched from the "recents" you can use intent flags.
if (getIntent().getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) {
// Lauched from recent apps.
}
Do NOT use a splash screen. It only slows down your app experience and has no value what so ever.
In addition... Android apps are a lose set of activities... There is no concrete entry point that would need a splash screen.
That said... the app switcher returns you to the previously active activity. In your case the .EventReceiver. You could change your structure by using a second activity that shows your ui so that the EventReceiver lets you forward to that.
Correct me if i am mistaken... But can't you intercept the nfc event with an receiver? From there you should open your ui activity.
I have a requirement that the title bar label on my launcher activity be different from the actual launcher label. This seems to work fine in the general case, however, I have a confirmed report from a user that their launcher label has changed over time to be the activity label. Here's an example:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:label="#string/activity_title"
android:name="MyActivity" >
<intent-filter android:label="#string/app_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Upon initial install, everything is correct. The launcher label shows up as the app_name string. When you launch the app the activity label is the activity_title string. However at some point the user opens up their app list and instead of seeing the app_name string for my app, they see the activity_title string.
They have installed multiple times and this seems to happen every time. Has anyone else seen this behavior and know of a way to resolve it?
EDIT:
After some more testing I figured out how to repro this every time with the manifest given above. If I install the app, then put a shortcut on the home screen and restart the emulator or device, then when it comes back up the shortcut has been renamed. The app in the app list is still correctly named. Weird stuff.
When my app first opens my first activity that is presented to the user can vary based on configuration options. I only know how to hard code the first activity that runs when the app is running by adding something like this in the Manifest
<activity android:label="#string/app_name" android:name=".MyFirstActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Where MyFirstActivity is the class name of the first activity class to be run. How can I dynamically select which activity to run first when the app is first launched rather than hard code it in the manifest?
Thanks!
Option #1: In onCreate() of MyFirstActivity, call startActivity() for the right activity, then finish().
Option #2: Define several activities with the LAUNCHER <intent-filter>, all but one disabled. On first run (or as needed), enable the right activity and disable the others. Downside: may require a phone reboot to update the launcher, since not all home screen launchers will detect your change.
Option #3: Redesign your GUI such that this is not an issue.
Hello
My application works like this.
StartUpActivity is called first, which does a lot of the init stuff
Then it launches TvbTabActivity (TabActivity) that has other Activities as its tabs (e.g. BrowseActivity).
The problem that I am seeing is this - when a task-killer app is used to terminate my app on TvbTabActivity/Browse tab, and the app is relaunched again, the system forgoes the normal flow (StartUpActivity is not spawned), but instead restores the last visible activity directly (TvbTabActivity).
How can i force Android to ALWAYS run StartUpActivity first, so that it initializes the app?
Obviously, I dont have this problem when my app crashes on its own, lol, due to an exception, and is then relaunched again.
<application android:icon="#drawable/appicon"
android:label="#string/app_name" android:name="com.xyz.QPApplication"
android:debuggable="true">
<activity android:name=".activity.StartUpActivity" android:configChanges="locale|orientation"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".catalogue.BrowseActivity" android:configChanges="locale|orientation"
android:label="#string/app_name" android:screenOrientation="portrait"
android:launchMode="singleTop">
<intent-filter>
<action android:name="com.xyz.android.intent.action.BROWSE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".activity.TvbTabActivity" android:configChanges="locale|orientation"
android:screenOrientation="portrait" android:launchMode="singleTask">
</activity>
You can't. Android will try to restore the app where it left off. The correct way to handle this is to ensure that you understand the Activity life-cycle and put the appropriate initialization in the appropriate place.
There are a couple of ways to solve your issue, the best would be to check the Android Life-cycle diagram http://code.google.com/android/images/activity_lifecycle.png and try to figure out a way to make the app work within that context.
Of course if you really want to you can kill your own app by calling Activity.finish() when it hits the onPause() or onStop() states, but that is quite an ugly solution.
You can't do anything about this -- what is happening to you is what the force stop API does and is intended to do.
Task killers are abusing that API.
They can no longer use it in 2.2 and later.
If you really want to avoid it, you could limit your app to only 2.2 or later. Or if the problem is users are complaining about them, tell them to stop using task killers. Or if the problem is just that you don't like this happening when you use a task killer, then don't use a task killer.
Also this is the same behavior that happens when the user presses "Force stop" in the manage application's UI. That is generally fine though since the user must explicitly do that, instead of what these task killer apps have been increasingly doing where they just whack stuff in the background without the user being directly involved.