Hi Mike,
I would suggest a better approach for this.
------------------------------------
Firstly I will put your problem in my worlds what I understand:
You have 3 Activities ActivityA, ActivityB, ActivityC.
ActivityA is starting activity.
Activities launch sequence is:-
ActivityA -->(On some user action) --> ActivityB --> (After some time,
say 5seconds) --> ActivityC
And closing sequence:-
ActivityC -->(On Back button press) --> ActivityA. (Skipping
ActivityB from stack) -->(Pressing back key from ActivityA will exit
the application)
--------------------------------------
Solution:-
-----------------
Step1- In ActivityA on some user action start ActivityB
public void someUserAction() {
Intent intB = new Intent(ActivityA.this, ActivityB.class)
startActivity (intB); // This will start ActivityB keeping
ActivityA below in the stack.
// Note: don't call finish() here, in this Activity.
}
----------------
Step2- In ActivityB, on some timer timeout, start ActivityC with
startActivityForResult
public void onSomeTimerTimeout () {
Intent i = new Intent(ActivityB.this, ActivityC.class);
startActivityForResult(i, 1001); // 1001 is just some request
code.
You will need this in onActivityResult() (step4)
// This will start ActivityC keeping ActivityB in
stack below ActivityC for the background blur look-n- feel as you
need.
}
-----------------
Step 3- In ActivityC handle back key press:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
setResult(RESULT_CANCELED);
// This will set the Result as RESULT_CANCELED and finish
this AvtivityC. Going back to ActivityB.
finish();
return true;
}
else {
return false;
}
}
------------------
Step4- Now back in ActivityB, override onActivityResult()
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (resultCode == RESULT_CANCELED) {
finish();
// This will check if the result is RESULT_CANCELED (set in
ActivityC), and finish this ActivityB without even showing up the
screen for ActivityB. So user will feel like going back to ActivityA
directly from ActivityC.
}
-----------------
Step5- Note: Keep all window manager flags (Blur, transparent)
unchanged. As per your requirement.
------------------------------
Try this out, and revert back in case of any queries.
--
Regards,
Udayan Warnekar
Android Application Developer
On Jun 16, 3:02 pm, mike <[email protected]> wrote:
> hi Sean,
>
> finally finally i have sorted out. but not 100% but by 99% i have
> achieved it.
>
> give me your mail address so i'll mail you a sample code.
>
> this is my Activity A
>
> public class blur extends Activity {
> /** Called when the activity is first created. */
> @Override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.main);
> startActivity(new Intent(blur.this, Transparent.class));
> //onPause();
> }
>
> @Override
> protected void onResume() {
> // TODO Auto-generated method stub
> if (Constants.isViewedMSG) {
> Log.d("RESUMEEEEEEE", "Resume activity");
> finish();
> }
> super.onResume();
> }
>
> }
>
> this is my Activity B
>
> public class Transparent extends Activity {
>
> @Override
> protected void onCreate(Bundle savedInstanceState) {
> // TODO Auto-generated method stub
> super.onCreate(savedInstanceState);
>
> getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
> WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
> setContentView(R.layout.trans);
> }
>
> @Override
> public boolean onKeyDown(int keyCode, KeyEvent event) {
> // TODO Auto-generated method stub
> if (keyCode == KeyEvent.KEYCODE_BACK) {
> // setResult(RESULT_CANCELED);
>
> finish();
> Constants.isViewedMSG = true;
> return true;
> }
> return false;
> }
>
> }
>
> this is my manifest.xml
>
> <?xml version="1.0" encoding="utf-8"?>
> <manifest xmlns:android="http://schemas.android.com/apk/res/android"
> package="com.randika.blur"
> android:versionCode="1"
> android:versionName="1.0">
> <application android:icon="@drawable/icon" android:label="@string/
> app_name" android:debuggable="true">
> <activity android:name=".blur"
> android:label="@string/app_name">
> <intent-filter>
> <action android:name="android.intent.action.MAIN" />
> <category
> android:name="android.intent.category.LAUNCHER" />
> </intent-filter>
> </activity>
> <activity android:name=".Transparent" android:theme="@style/
> Theme.Blue"/>
> </application>
> <uses-sdk android:minSdkVersion="4" />
>
> </manifest>
>
> this is my theam.xml
>
> <?xml version="1.0" encoding="utf-8"?>
> <resources>
> <style name="Theme.Blue"
> parent="android:style/Theme.Translucent">
> <item name="android:windowNoTitle">true</item>
> <item name="android:colorForeground">#fff</item>
> </style>
> </resources>
>
> this is my Constant class
>
> public class Constants {
> public static boolean isViewedMSG = false;
>
> }
>
> if you went through the source code you'l see the i have override
> onResume method.
> there i'm checking the Boolean value and according to boolean i'm
> finishing the Activity A
>
> regards,
> MIke
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en