Tuesday, April 8, 2014

A start-B program android program, several issues! ~


I want to implement a program (A) start another program (B), then A is minimized (hidden) again after the display B A

A code
{
ComponentName componentName = new ComponentName ("com.example.test2", "com.example.test2.MainActivity");
Intent intent = new Intent ();
intent.setComponent (componentName);
intent.putExtra ("name", "test1");
startActivity (intent);
/ / How to hide A? ? ? ? ?
}

B code
{
/ / How to display A? ? ? ? ?
finish ();
}
Another point, B of A is displayed when not in walking A's onCreate
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Who will help me find ah ~ headache hey! ~ Android just study! ~ Big O God, please enlighten me ah! ~ Share ah! ~
Reply:
startActivityForResult ()
Reply:
I do not know restarting an Activity okay
 Intent intent = new Intent (); 
intent.setClassName ("A", "B");
startActivity (intent);

Reply:
Thank you two good-hearted people, ah, I was two works, it seems not directly setclass it! ~
Reply:
A finnish off (also equivalent to hide it) to open the onFinish B B A re-open
Reply:
A finnish off the open B B A onFinish open again it will take the A's ONcreate
Reply:
Internet search invoke this.moveTaskToBack (true); to hide A
But B is not open @!

A code
{
ComponentName componentName = new ComponentName ("com.example.test2", "com.example.test2.MainActivity");
Intent intent = new Intent ();
intent.setComponent (componentName);
intent.putExtra ("name", "test1");
startActivity (intent);
/ / How to hide A? ? ? ? ?
/ / This.moveTaskToBack (true); / / B open
/ / Finish (); B play on, but the A, B Open A walk Oncreate
}


Reply:
First, startActivity (B), regardless of whether the A finish are hidden,
Call the finish and not only have an impact on onDestroy method call. If you execute the finish,
How does onCreate it? From a life cycle perspective, as long as the A method will perform onStop becomes invisible,
Unless style B is floating in. Propose to look at the life cycle of Activity learn a little more thorough,
The problem will be more clearly explained it, others can be more easily understood.
But now the problem you described: A no action, B executed finish will show A
Reply:
ri, really, ah, so simple. . . . . . . .
Reply:
Supreme ah, hey, engage in a day! @ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ What code is not on the list
A code
{
ComponentName componentName = new ComponentName ("com.example.test2", "com.example.test2.MainActivity");
Intent intent = new Intent ();
intent.setComponent (componentName);
intent.putExtra ("name", "test1");
startActivity (intent);
}
B does not require any code. . . . .
Reply:
I want to implement a program (A) to start another program (B), triggering events for B b program into the background, back to the A (a not perform oncreate method), and a wake-up b, b do not perform oncreate method shows again . How to get this, find the Great God. .

No comments:

Post a Comment