Wednesday, April 23, 2014

100 How to disable Activity onCreate again


Premise 1: not allowed to use android: launchMode = "singleTask"
Premise 2: not allowed to use Intent.FLAG_ACTIVITY_NEW_TASK
Problem: Press the Home key to hide the program after the call again ban Activity re onCreate, but directly displayed
.Solvers can ask yourself to how many points are OK, as long as I am within the available scores.
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
onSaveInstance ()?
Reply:
Press the Home key to hide the program later, in accordance with the principle that you can not control it may not be the system to kill (there are ways to improve their chances of not killed), was killed and then evokes'll go oncreat, this should be no doubt that (as far as I Understanding).
Advice I give is to try not to be killed so that activity seems to bind a background service can be, right? Or is the best way to hack has no sound playing music (ios5 more background processes is so implemented).
Hundred percent not necessarily solve the problem, I hope to give you an idea, or a little help now
Reply:
reference to the second floor of the reply:
press the Home key to hide the program later, in accordance with the principle that you can not control it may not be the system to kill (they do not have the means to enhance killed probability), killed and then evokes'll go oncreat, this should be no doubt that (as I understand it).
Advice I give is to try not to be killed so that activity seems to bind a background service can be, right? Or is the best way to hack has no sound playing music (ios5 more background processes is so implemented).
Hundred percent not necessarily solve the problem, I hope to give you an idea, or a little help it

Press the HOME key is actually no Destroy, but re startActivity re OnCreate, then the original is not Destroy Destroy will be out of time and I want is not Destroy
Reply:
After pressing the HOME button, then back to the application, if the process has been killed will re onCreat, not to be killed, then run the onResume, not re-run the onCreate
Reply:
Forced to shut down your system when you are not calling onDestroy activity, but in time to resume your activity will call onCreate (Bundle), where there is a bundle of data, and the data that you saved in onSaveInstanceState, and < br />Just do save and restore data just fine.
Reply:
I generally understand what you want, and then go home, startActivity is inside your own program to call it? Or be reminded once again of the launcher?
The first can be achieved by adding some of the flag, and if the second onNewInstance will call it?
Reply:
Usually you have no way to prevent the system mandatory end (upstairs that background music playing silent way I have not tried, perhaps feasible) of your program, so it is best not to think about how to prevent the system re-oncreate, but against the onCreate The bundle doing restoration work.
Reply:
For this procedure, shielding the Home key, minimize activity, look at the following code
 
@ Override
public boolean onKeyDown (int keyCode, KeyEvent event)
{

if (event.getAction () == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_HOME)

{

/ / Minimize applications

Intent intent = new Intent (Intent.ACTION_MAIN);

intent.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK);

intent.addCategory (Intent.CATEGORY_HOME);

startActivity (intent);

return true;

}

return super.onKeyDown (keyCode, event);

}

Of course, even onAttachedToWindow and Canadian Shield Home android.permission.DISABLE_KEYGUARD
Specific examples of the investigation, android home button to minimize shield
Reply:
I say way too hack the music, not the best, the costs of electricity.
I also agree oncreate time doing data recovery may reduce the startup time
Reply:
references, 4th Floor reply:
press the HOME key, the time to return to the application, if the process has been killed will re onCreat, not to be killed, then are running onResume, not re-run the onCreate

Map I tune up is not OnDestroy press HOME, but when I again startActivity will re OnCreate, then is not the last time the Activity will be OnDestroy OnDestroy out, a few floors above methods are ineffective.
Reply:
Proposed landlord to change the framework to achieve
Reply:
lz Why "again startActivity"? Where there is not a logical problem
Reply:
reference to the 12th floor of the reply:
lz Why "again startActivity"? Where there is not a logical problem

Because press the HOME key, the program goes to the background, and not to the front startActivity can show it?
Reply:
startActivity, then you can add another intent inside the flag, there is a can reorder Activity, perhaps you can help
Reply:
reference to the 14th floor of the reply:
startActivity, then you can add another intent inside the flag, there is a can reorder Activity, perhaps you can help

FLAG_ACTIVITY_REORDER_TO_FRONT not meet the requirements of FLAG_ACTIVITY_NEW_TASK is to let the map does not re-OnCreate, but let me start the Activity map of APK not play in front of the map, but Maps were blocked.
Reply:
reference to the 15th floor Reply:
reference to the 14th floor of the reply:
startActivity, then you can add another intent inside the flag, there is a can reorder Activity, perhaps you can help

FLAG_ACTIVITY_REORDER_TO_FRONT can not meet the requirements of FLAG_ACTIVITY_NEW_TASK is to let the map does not re OnCreate, but let me start the Activity map of APK not play in front of the map, but the map has been blocked .......
< br />
APK's Activity Map and startup map What is the relationship?
Reply:
Estimate is difficult to achieve the application layer, mark down

Reply:
reference to the 16th floor of the reply:
reference to the 15th floor Replies:
References to the 14th floor of the reply:
startActivity, then you can add another intent inside the flag, there is a can reorder Activity, perhaps you can help

FLAG_ACTIVITY_REORDER_TO_FRONT can not meet the requirements of FLAG_ACTIVITY_NEW_TASK is to let the map does not re OnCreate, but let me start the Activity map of APK not play to ......

Start map APK is what I do a Lanucher
Reply:
After pressing the home button, activity should be in pause state, if not finish or is android kill off then,
Start again should not be executed OnCreate.
In addition, the 8th floor of the way I tested without success.
Taking part!
Reply:
reference to the 19th floor Reply:
after pressing the home button, activity should be in a pause state, if not finish or is android kill off then,
Start again should not be executed OnCreate.
In addition, the 8th floor of the way I tested without success.
Taking part!

I wrote the other APK is normal, there is the problem that the map
Reply:
reference to the 17th floor Reply:
estimated application layer is difficult to achieve, the next mark

Application layer should be able to achieve it, such a simple function this way?
Reply:
/ / --------------
http://topic.csdn.net/u/20121018/12/7c3af197-b4f4-4b73-9e02-ecb510eeb476.html?48255
I wrote a Lanucher, this Lanucher start of the map, and then I wait 30 seconds after the Lanucher will automatically call startActivity to launch an activity Lanucher itself, is now being launched this activity can not be displayed on the map, what can it displayed on the map.
Note: The map uses the android:. LaunchMode = "singleTask" to ensure that only start once
/ / ------------------

The landlord of the problem with the above problems, it should be essentially the same problem, and will re-call oncreate, under normal circumstances, the system is to be so moves (unless any special way with, but really do not get recommended so unless you want to Through a system of non-customized version),
See if I can change the ideas, such as to make some changes on the map invocation.
Reply:
The reply was deleted at the moderator 2012-10-24 13:08:22

Reply:
Press the home button, and then enter the application should not go oncreate, you are not out of the question design logic? You are not themselves put their finish out of it?
Reply:
Because >>> press the HOME key, the program goes to the background, and not to the front startActivity can show it?

First, press the HOME back to the launcher, and then click on the program icon from the launcher to start the program above is not to go oncreate, and this should be no problem.

The landlord wanted to start your own code again, so I suggest the landlord to see how the launcher to start the program. It can do it, you should also be able to do.

By the way, why not use "singleTask"?
Reply:
oncreate only called once again wake up without calling
Reply:
reference to the 25th floor of the reply:
>>> because press the HOME key, the program goes to the background, and not to the front startActivity can show it?

First, press the HOME back to the launcher, and then click on the program icon from the launcher to start the program above is not to go oncreate, and this should be no problem.

The landlord wanted to start your own code again, so I suggest the landlord to see how the launcher to start the program. It can do it, you should also be able to do.

Yes, why not "sing ......

launcher plus NEW_TASK property, I can not add, plus a map interface does not pop up in front of me to be seen:
http :/ / topic.csdn.net/u/20121018/12/7c3af197-b4f4-4b73-9e02-ecb510eeb476.html? seed = 135934681 & r = 79926450 # r_79926450
Reply:
The reply was deleted at the moderator 2012-10-25 11:31:37

Reply:

android: name = ". app.entry.BootActivity"
android: label = "@ string / app_name"
android: theme = "@ style / translucent"
android: launchMode = " singleTop ">
Reply:
reference to the 29th floor of the reply:
android: name = ". app.entry.BootActivity"
android: label = "@ string / app_name"
android: theme = "@ style / translucent"
android: launchMode = "singleTop">

singleTop I had tried, and NEW_TASK like my Activity will not be displayed above the map.
Reply:
Like a seesaw, nobody can get ah
Reply:
One of the written word has 14 kinds of what?
Why are not allowed to use
Reply:
singleInstance

No comments:

Post a Comment