I think I need some help understanding how Bundles are handled on Destroy. I have an issue with my App where a bundle becomes null when its closed overnight or over several hours etc. But i cannot replicate this for debugging purposes. No matter what I do, the bundle remains intact after supposed forced destroys etc
To replicate the issue I've tried two different things:
Using the option under Developer options IIRC - Settings>Developer Options > Don't Keep activities.
Using the "STOP" button under eclipse DDMS.
Neither of these seem to remove the Bundle. Am I missing something, how is the bundle retained after a supposed full destroy?
I'm using a Nexus 5, android 4.4.2
I have a check in my "preferences" class, which firstly checks if Bundle variables are available from a logical previous/parent Activity, if not it reads from Android SharedPreferences. The problem is I must have an issue when I check the bundle is not null. So I need to debug this as its allowing null values to be set from the bundle to my "session" ID's
Am I missing something? Surely the bundle should be destroyed along with my App, but when using option 1) above, the Bundle still exists so i can't debug my IF statement. Option 2) is not useful because the stop button seems just to close the active Activity - my app steps backwards through the hierarchy of screens as I click stop. Again not destroying the entire application from memory. I must be missing something fundamental!
Cheers for any help.
BTW, I've search for all solutions on SO I could, everything just seems to be using the optoins above with no issues, is something possibly different with a my Android OS/Phone?
Edit: This article by Google shows the functionality I need but i assume this is an outdated article and its referring to what I try in option 1)? -
See "Immediately destroy activities" - developer.android.com/tools/debugging/debugging-devtools.html
Edit2: see the comments below I mistakenly thought the above Google doc was referring to removing an entire application from memory rather than just an Activity. Anyway for now I'll try something like this to check the bundle value
Long val = bundle.getLong(Navigator.INTENT_KEY_CHANNEL_ID, 0);
if (val != 0 && val != null) {
}
1- Launch your application
2- Press Home Button
3- Launch DDMS in Android Studio or Eclipse
4- Select your app and click stop
5- Choose your app launched app history
Thanks,
Related
When testing on a device in Android Studio you get an awful lot of output in the logcat.
I'm only interested in the output for the app I'm developing. I can see just this, after running, by opening the Devices section and manually selecting my apps process. Problem is, it's pretty tedious to do this every time I run my app, which seems to be the case.
Is there a way to get it to remember this setup?
How about a way to get it to stop reporting anything after I'm done with my app or it's crashed ? (otherwise my app specific stuff gets buried so quickly by output from other proccesses on my phone)
I'm open to other ways of filtering the logcat too, however I couldn't think of a way to set up filters so that I would get my tagged Log messages AND other exceptions I wasn't expecting.
Any suggestions?
Normally this is done by default, but if not,
in logcat, the green plus sign, when you click it you get a dialog, fill the byApplicationName with your package name, and also your filter name with something, now you can filter your output according to your app
with that beeing said, sometimes you don't get the filter column info (application name) in logcat at all (blank), here (and I my self don't know the cause of it) just forget it for a while and retry again
I've created an app that has been in the android marketplace for a few months now. I'm trying to create a complimentary app that will be used inside the first app. I need the second app to be optional, and not necessary for the first app to work properly. I'm hoping to call the main activity from the second app within a Tab Host tab on the first app.
My questions are: how do I run an activity from a secondary app with a different package? Is it possible to have the activity be in a tab host?
I'd be happy to post code, but my code seems to be nowhere close to what I'm trying to get. I don't think I can adjust the build path of the primary app, because the secondary app can't be required. Also, Since the app has been in the marketplace for a while, I can't use SharedUserIds.
Thanks for all help.
TJ
It is not possible to do it to run any arbitrary activity in your app.
I have done this before, with activity group, which has been already deprecated. And there are also limitations to use this approach:
Your app has the same UID with the target package.
Your app has system UID
If you met either condition list above, you can start the child activity and get its window root view, and add into your layout.
Is it possible to have a safe start mode for your Android Application. In the sense that the application will not start the main activity (which is intense) but will open another activity which will have tools to fix some of these problems.
My suggestion would be to create flag in shared preferences to store whether your app was closed properly or check something else you need. Then add one part before (activity or what you need) where you check this and decide about the mode you are getting in.
Hope this helps and enjoy your work.
I'm developing Activity which works on data passed in Intent in extras.
This Activity is supposed to be launched by other activities in my app.
However, during development/debugging, I launch this Activity directly, and want to simulate extras in Intent (obtained from getIntent) to pass in desired testing params (sort of command-line parameters).
In Eclipse Run configurations, I can just select Launch action, but no additional data.
Is there some way? Or I must hardcode testing params in java, and not forget to comment them out when testing is finished?
I think eclipse is just using something comparable to the am start method to launch an application. You should be able to do this manually via adb and specify extras; then once you have it working from the command line you can put it behind a button using eclipse's extensibility features.
Here's a writeup found during a brief search: http://learnandroid.blogspot.com/2008/01/run-android-application-from-command.html
I think you may want to just write some proper tests for this purpose.
Take a look at this:
Android Testing fundamentals
You could then be running your test during development, which would launch the Activity as you want it.
I was studying some sample examples for Android and one of them got me really curious:
the NoteList (or Notepad) example application - here
My question is: Is there any way to make a NoteList shortcut, that always starts the application with its 'Editor' activity, for example. [of course if the creator of that 'third-party' application intended to make it possible by describing the entry points of its application in a proper way in the manifest file. I do not intent to create malware.]
in other words:
Can a third-party application (like the one I wish to make :) ) to get to internal application intents {i.e. action, activity, data} or this is handled by Android and no one else?
What gave the idea that this is possible was the following case:
I opened NoteList, created a few note, and when I was editing the title of one of the notes - I pressed HOME, when I clicked on the icon of NoteList I got the exact same state of the application - editing the title of the note.
thanks!
One has nothing to do with the other. That means that reopen an activity which was paused or killed with a data restoring logic just restores the last state. This is what happened in your example.
Now what you mean I guess is if there is a way to tell Android that you application can do a certain thing thus it should be shown as an option in the action chooser. Yes that is possible through intent filters.
The Intent reference page might also be very informative for you.