Android Safe Start Mode for Application - android

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.

Related

Force Destroy of app for testing

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,

Check for Android Application is First run or not?

I am new to android development. I know we can check for application first run using preferences. But My Question is - If it is first run i should get a First(splash) form where i should get a string and save it in SQLite(Database). Second time i should check the database if the string exists I should get the Second(Login) form. I tried many ways its not working.
Can any one help me out with a detailed code. Thanks in Advance.
Why don't you just write an if else statement in the main method of the main page?
If first launch > splashscreen redirect
If run xx > Login redirect.
To detect the first time an app is launched you could make a sharedPreference (see this thread: How to use SharedPreferences in Android to store, fetch and edit values or Check if application is on its first run)
Good luck.
Define a startup activity without a view, and in its onCreate method, check (using SharedPreferences) if this is the first run. If so, go to the splash screen, otherwise go to the login screen.

Referencing another package activity within a tab host

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.

How to create service project without any activity?

Just starting with android.
I try to create project that will send notification ( some bit for example ) to my FTP server every 3 hours.
I don't know how to create this project because each time i create new android project i must have only project with activity - and i don't need any activity - just need a service that will run when i install it on the device.
each time i create new android project i must have only project with activity
If you are using Eclipse, uncheck the "Create activity" checkbox that tells the new project wizard to create an activity.
If you are using android create project, yes, it will create an activity for you. You can delete the Java class and the manifest <activity> entry if you want.
In reality, you will wind up leaving all of it alone.
just need a service that will run when i install it on the device.
First, a service does not run just because you install it on the device. It only runs if you write code to cause it to run.
Second, while you might think "well, I will just get control at boot time and start the service then", that is possible, but it will not work on Android 3.1+ devices unless the user has run an activity first. This is to prevent "drive-by" malware.
So, I suggest that you leave the activity in there, if you want your app to work.
Moreover, unless this app is only for yourself, your users need the activity, to:
Control the behavior of the service, such as changing the "every 3 hours" setting to something they prefer
Read your license agreement
Read your documentation, including how to get support
Etc.

Who manages interlal application intents?

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.

Categories

Resources