Android : Handeling StartActivityForResult On Back Button

Jul 14, 2009

I am working on an app and I use startActivityForResult but currently if you press the back button on the new activity it will crash my app. In my new activity I have

CODE:..........

But that didn't fix the problem.

Android : handeling StartActivityForResult on back button


Motorola Droid X : Back Button Functionality - Cannot Simply Go Back One Menu Using The Back Key

Jul 15, 2010

This is my first android device and i'm loving it... but one thing that irks me is the use, or lack thereof, of the back button.

As I am navigating menus and options in the Settings, I cannot simply go back one menu using the back key. For example, if I go to Settings->Battery Manager->Battery Profile Options and want to go back to the Settings screen, I cannot.

Pushing the back button does nothing and I can only go back to the Settings menu by going Home, then re-entering.

Another quirk regarding the back button is when reading emails. Using a regular email account such as Hotmail, I cannot simply read an email and go back to the inbox using the button.

It makes navigating the phone very tedious.

View 5 Replies View Related

Android :: How To Control Activity Flow - Back Button Versus Home Button

Sep 2, 2010

I have 3 activities in my app: Activity1 -> Activity2 -> Activity3. Inside Activity3, if the user presses Back, I would like to return to Activity2. In Activity3's onPause event, I added a finish() statement. That's probably not even necessary, but I wanted to make sure this Activity gets cleaned up. This works fine.
However, while in Activity3, if the user presses Home or starts a new app (through notification bar or some other means), I want both Activity3 and Activity2 to finish. If the user returns to this app, he should resume with Activity1.

I have figured out how to do one or the other, but I can't figure out how to handle both cases, if it's even possible. Can I trap the "Back" button in Activity3 and send a message back to Activity2 telling it not to finish()? It seems like the Activities follow the same lifecycle flow (Pause, Stop) regardless of what you do to send them to the background. Just to answer the question of why I want this behavior, imagine that Activity1 is a login screen, Activity2 is a selection screen, and Activity3 is a content screen. If I press Back from the content page, I want to be able to make a new selection. If I exit via any other means (Home, notification bar), I want the user to be "logged out".

View 2 Replies View Related

Android :: WebView.clearHistory() - Don't Want Back Button To Allow User To Go Back Further Than Current Session

Mar 31, 2009

I call WebView.clearHistory(), but I am still able to go back after doing so. I want to reuse a WebView, but I don't want the back button to allow the user to go back further than the current "session" of using the WebView. Anybody know what is the best way to handle this? I thought for sure that clearHistory() would do it.

View 3 Replies View Related

Android : Back Button - Disable In Buffering Or Should Prevent The Player Tostart If Back Is Clicked

Oct 11, 2010

In my android application i have a video list screen,a buffering screen and a videoplayer screen.
As soon as the user clicks an item from videolist screen ,he is navigated to buffering screen and then to videoplayer.
In the buffering screen i am using Async task and doing the loading process in on background process.

Now my issue is like the user if has selested a video then gets navigated to buffering screen.But if the user clicks back when he is in buffering screen then initially he is getting navigated to videolist screen but immediately after that again he is navigated to videoplayer screen.

What i would like to have is either the back button should be made disable in buffering or should prevent the player tostart if back is clicked.

View 2 Replies View Related

Android :: Ok Button On AlertDialog Should Work As Back Button

Jun 16, 2009

In My code I am displaying a AlertDialog based on some condition.

CODE:.......................

View 2 Replies View Related

Motorola Droid X : Back Button - Swipe Left To Right On Maybe The Top Bar It Goes Back

Jul 19, 2010

I'm finding that I'm using the back button A LOT whether browsing the web or just navigating the OS. It kind of sucks because the buttons on the droid x are well, really small, and sometimes hard to press because they are so narrow and flimsy feeling. And depending on how you are holding the phone, it could be a good bit of distance for your thumb to travel or I'm finding myself having to reposition the phone in my hands just to reach the back button, which you seem to need very frequently.

Anyone know of any kind of back 'swipe' implementation ? Like some software you can install that makes it if you swipe left to right on maybe the top bar it goes back?

View 4 Replies View Related

HTC Incredible :: Swiping Down Notification Bar / Back It Up - Hit Back Button?

May 5, 2010

Instead of trying to grab the notification bar and swiping it down, simply start ABOVE the screen and swipe down. Fast or slow makes no difference.

You can swipe it back up, or simply hit the back button.

View 15 Replies View Related

General :: Have To Click Back Button 2x In Browser To Go Back?

Sep 8, 2013

In the last few days I am having to press the back button twice when using both the stock android browser and the latest version of chrome on my rooted S3.

View 4 Replies View Related

Android :: StartActivityForResult Function ?

Sep 23, 2009

I have a problem with the startActivityForResult function?

My code:

CODE:..........

But the second intent is only starting and if i finish the second intent (getPicture), the first intent is called. Why?

The logcat shows:

CODE:.......

So why the savefilename-activity doesn't start first?

View 3 Replies View Related

Android : Use StartActivityForResult From Non-activity?

May 17, 2010

I have MainActivity which is an Activity and other class(which is a simple java class), we`ll call it "SimpleClass".
now i want to run from that class the command startActivityForResult.

now i though that i could pass that class(SimpleClass), only MainActivity's context, problem is that, u Cant run context.startActivityForResult(...);

so the only way making SimpleClass to use 'startActivityForResult; is to pass the reference of MainActivity as an Activity variable to the SimpleClass
something like that:

inside the MainActivity class i create the instance of SimpleClass this way:

SimpleClass simpleClass=new SimpleClass(MainActivity.this);

now this is how SimpleClass looks like: code...

now its working, but isnt a proper way of doing this? I`am afraid i could have some memory leaks in the future.

View 2 Replies View Related

Android : Tap Activity After StartActivityForResult?

Nov 23, 2009

I have two buttons in an activity/view A0, b1 and b2 that respectively starts (for result) the activities A1 and A2. After tapping/clicking b1 I quickly tap b2 aswell. The result will be that both A1 and A2 are launched. Is there any obvious way to not have this behaviour, i.e. to "lock" A0? I am thinking of overriding dispatchTouchEvent to consume everything after the call to startActivityForResult, but it seems a bit much...

View 2 Replies View Related

Android :: Android - Override Back Button To Act Like Home Button

Jan 4, 2010

On pressing the back button, I'd like my application to go into the stopped state, rather than the destroyed state. In the Android docs it states: not all activities have the behavior that they are destroyed when BACK is pressed. When the user starts playing music in the Music application and then presses BACK, the application overrides the normal back behavior, preventing the player activity from being destroyed, and continues playing music, even though its activity is no longer visible


How do I replicate this functionality in my own application? I think there must be three possibilities.

1) Capture the back button press (as below) and then call whatever method(s) the home button calls...........

View 2 Replies View Related

Android :: Changing Back Button Press To Home Button Press

Sep 1, 2009

Trying to the do as the title describes with the following code, but it doesn't seem to work. It just does nothing once i have altered the keyCode. Do i have to do something to the event?
..............

View 8 Replies View Related

Android : Way To Use StartActivityforResult() For Email Intent

Sep 23, 2010

I am using intent for send email with attachment,it is work fine,i want to get this email intent result,i already used startActivityforResult(),but i can't get result for email intent,how can we use startActivityforResult() for Email intent?

View 1 Replies View Related

Android :: Sending / Receiving Data Using StartActivityForResult

Apr 21, 2009

Ok, I have 2 Activities I want to send data between activity A and B.My problem is that some random code of mine seems to be called between startActivityForResult() and onActivityResult()in Activity A.This doesn't make any sense because there is no code after startActivityForResult() is called.Shouldn't onActivityResult() be the first thing A does after B finishes?

View 2 Replies View Related

Android : How Activity.finish() / StartActivityForResult() Collaborate With Each Other

Nov 12, 2010

I got a question about Activity.finish(). In my Android code, there are 4 activities(A,B,C,D). The starting activity A calls startActivityForResult(intent, reqCode) to start activity B. B starts C, and then finish(), not waiting for result. C does exactly the same as B, starts D and then finish(). D will return some result, by setResult(resultCode).

When my code runs and activity D returns some result, A will catch a RESULT_CANCELED on onActivityResult(), even if RESULT_OK is returned in D. I guess the RESULT_CANCELED is from activity B, which has been terminated before D returns a result, rather than from D.

But, my question is, why activity A catch RESULT_CANCELED after D returns some result, rather than immediately after B is terminated? And, what should I do to make A catch results from D? Do I have to keep B and C alive, to pass results from D to A?

View 2 Replies View Related

Android :: How To Pass Large Amount Of Data During StartActivityForResult

Nov 3, 2009

From one activity, I want to pass a lot of data (about 1MB of Strings).I tried sticking it in Intent.putExtra(ArrayList<String>), but if I put in too much data, I get "FAILED BINDER TRANSACTION".What's the easiest way? I don't want to publish a service, or use the file system. I really want a pipe that can write data from one end and read it from the other end. I can handle the case where the starter Activity dies while the "startee" activity is trying to read from the pipe.

View 6 Replies View Related

Android : Return A Result (startActivityForResult) From A TabHost Activity?

Mar 23, 2010

I have 3 classes in my example:
Class A, the main activity. Class A calls a startActivityForResult:

Intent intent = new Intent(this, ClassB.class);
startActivityForResult(intent, "STRING");

Class B, this class is a TabActivity:

Intent intent = new Intent(this, ClassC.class);
tabHost.addTab...

Class C, this class is a regular Activity:

Intent intent = this.getIntent();
intent.putExtra("SOMETHING", "EXTRAS");
this.setResult(RESULT_OK, intent);
finish();

onActivityResult is called in Class A, but the resultCode is RESULT_CANCELED instead of RESULT_OK and the returned intent is null. How do I return something from the Activity inside a TabHost?

I realize that the problem is that my Class C is actually running inside of Class B, and Class B is what is returning the RESULT_CANCELED back to Class A. I just don't know a work around yet.

View 4 Replies View Related

Android : Lifetime Of Background Parent Activity After StartActivityForResult()?

Jul 19, 2010

Is there an exception in the lifetime rules for a parent activity that's in the background after invoking startActivityForResult()? From my understanding, in low memory scenarios, the background activities are killed before the foreground. Does this rule still apply even if the background activity started the foreground one for the purpose of obtaining some result?

In this case, I think it would make sense for the foreground child activity to get killed first or to equalize the lifetime of the parent and child.

View 5 Replies View Related

Android :: Using Back Button

Jul 15, 2010

I am a new to android development I want to override the default back button operation in android,please let me know how i can do this in code.

View 3 Replies View Related

Android :: Back Vs Home Button

Jul 4, 2010

This has been brought up before, but I was unable to find a satisfying answer. And I know it's a newbish question.

What is the difference between exiting an app with the back button compared to the home button? I am not talking about switching to the home screen, I am talking about a scenario when you want to exit an app. For example, you play a game, you're done - do you press home or back? Or, you're in the Facebook app and you want to exit to the homescreen - what do you press - back or home? At first, I thought both buttons do the same with the difference that home brings you to the homescreen instantly while back goes through your previous steps/pages/screens in the current app and then returns you the homescreen.

But later I noticed that 'reactivating' some apps that were exited via the back button cause them to 'reload' (the loading screen shows up - with certain games, grooveshark's loading screen, etc.) while they switch back instantly when "exited" with the home button.

I gather the way to 'leave' an app you don't plan on using for at least a short while (I am not talking about closing the app, I know it's up to Android, or some task-killer) is the back button, while home is more for task switching/starting new apps while old ones are running.

View 8 Replies View Related

Android :: Control Back Button

Aug 12, 2009

I want to get the Text data value from Sub-Activity back. And everything is ok. But when the Sub-activity was opened, then I just click back "button" on the phone, it throw an exception error. I found on the android NotePad life-cycle control toturial but It's hard to understand. Can someone help me? This is my code:
public class SBooks extends ListActivity {
private String title_raw;
private SBooksDbAdapter mDbHelper;private static final int ACTIVITY_SEARCH = 0;private static final int SEARCH_ID = Menu.FIRST; @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sbooks_list);
mDbHelper = new SBooksDbAdapter(this);
mDbHelper.open();
Create Menu Option
@Override public boolean onCreateOptionsMenu(Menu menu) {
boolean result = super.onCreateOptionsMenu(menu);
menu.add(0, SEARCH_ID, 0, R.string.menu_search);
return result;
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()){
case SEARCH_ID:
Intent intent = new Intent(this, SBooksSearch.class);
startActivityForResult(intent, ACTIVITY_SEARCH);
return super.onOptionsItemSelected(item);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent){
super.onActivityResult(requestCode, resultCode, intent);
switch(requestCode){
case ACTIVITY_SEARCH:
Bundle bundle = intent.getExtras();
title_raw = bundle.getString(SBooksDbAdapter.KEY_TITLE_RAW);
if(title_raw!=null){
Cursor cursor = mDbHelper.searchData(title_raw);
String[] from = new String[]{ SBooksDbAdapter.KEY_ROWID,
SBooksDbAdapter.KEY_TITLE, SBooksDbAdapter.KEY_LYRICS };
int[] to = new int[]{ R.id.id, R.id.title, R.id.lyrics };
SimpleCursorAdapter adapter =
new SimpleCursorAdapter(this, R.layout.sbooks_row, cursor, from, to );
setListAdapter(adapter);This is my Sub-Activity:
public class SBooksSearch extends Activity {
private EditText mTextSearch;
private Button searchButton;
private SBooksDbAdapter mDbHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.sbooks_search);
mTextSearch = (EditText)findViewById(R.id.text_search);
searchButton = (Button)findViewById(R.id.btn_search);
searchButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
Intent intent = new Intent();
intent.putExtra(SBooksDbAdapter.KEY_TITLE_RAW, mTextSearch.getText().toString());
setResult(RESULT_OK, intent);
finish();
@Override
protected void onSaveInstanceState(Bundle outState){
super.onSaveInstanceState(outState);
@Override
protected void onPause(){
super.onPause();
checkState();
@Override
protected void onResume(){
super.onResume();
}private void checkState() {
This is Logcat:
08-12 18:44:39.211: WARN/InputManagerService(581): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@43719140 (uid=10004 pid=623)
08-12 18:44:39.510: INFO/ActivityManager(581): Displayed activity com.original.sbooks/.SBooks: 4934 ms
08-12 18:44:40.821: WARN/KeyCharacterMap(730): No keyboard for id 0
08-12 18:44:40.821: WARN/KeyCharacterMap(730): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
08-12 18:44:41.412: INFO/ARMAssembler(581): generated scanline__00000177:03515104_00001A01_00000000 [ 64 ipp] (89 ins) at [0x297608:0x29776c] in 952924 ns
08-12 18:44:41.520: INFO/ARMAssembler(581): generated scanline__00000177:03515104_00000A01_00000000 [ 46 ipp] (70 ins) at [0x297798:0x2978b0] in 517061 ns
08-12 18:44:42.171: INFO/ActivityManager(581): Starting activity: Intent { comp={com.original.sbooks/com.original.sbooks.SBooksSearch} }
08-12 18:44:52.196: WARN/ActivityManager(581): Launch timeout has expired, giving up wake lock!
08-12 18:44:52.279: WARN/ActivityManager(581): Activity idle timeout for HistoryRecord{436bfc80 {com.original.sbooks/com.original.sbooks.SBooksSearch}}
08-12 18:44:57.350: DEBUG/dalvikvm(620): GC freed 4103 objects / 231808 bytes in 75ms
08-12 18:45:05.130: DEBUG/dalvikvm(649): GC freed 2604 objects / 150112 bytes in 88ms
08-12 18:45:10.120: DEBUG/dalvikvm(623): GC freed 2750 objects / 149592 bytes in 71ms
08-12 18:45:11.920: INFO/ActivityManager(581): Displayed activity com.original.sbooks/.SBooksSearch: 29748 ms
08-12 18:45:17.263: WARN/ActivityManager(581): Activity pause timeout for HistoryRecord{436bfc80 {com.original.sbooks/com.original.sbooks.SBooksSearch}}
08-12 18:45:26.762: WARN/ActivityManager(581): Launch timeout has expired, giving up wake lock!
08-12 18:45:27.272: WARN/ActivityManager(581): Activity idle timeout for HistoryRecord{435a7760 {com.original.sbooks/com.original.sbooks.SBooks}}
08-12 18:46:04.905: DEBUG/AndroidRuntime(730): Shutting down VM
08-12 18:46:04.905: WARN/dalvikvm(730): threadid=3: thread exiting with uncaught exception (group=0x4000fe70)
08-12 18:46:04.905: ERROR/AndroidRuntime(730): Uncaught handler: thread main exiting due to uncaught exception
08-12 18:46:04.991: ERROR/AndroidRuntime(730): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=0, data=null} to activity {com.original.sbooks/com.original.sbooks.SBooks}: java.lang.NullPointerException
08-12 18:46:04.991: ERROR/AndroidRuntime(730): at android.app.ActivityThread.deliverResults(ActivityThread.java:3005)
08-12 18:46:04.991: ERROR/AndroidRuntime(730): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3047)
08-12 18:46:04.991: ERROR/AndroidRuntime(730): at android.app.ActivityThread.access$2300(ActivityThread.java:112)
08-12 18:46:04.991: ERROR/AndroidRuntime(730): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1721)
08-12 18:46:04.991: ERROR/AndroidRuntime(730): at android.os.Handler.dispatchMessage(Handler.java:99)
08-12 18:46:04.991: ERROR/AndroidRuntime(730): at android.os.Looper.loop(Looper.java:123)
08-12 18:46:04.991: ERROR/AndroidRuntime(730): at android.app.ActivityThread.main(ActivityThread.java:3948)
08-12 18:46:04.991: ERROR/AndroidRuntime(730): at java.lang.reflect.Method.invokeNative(Native Method)
08-12 18:46:04.991: ERROR/AndroidRuntime(730): at java.lang.reflect.Method.invoke(Method.java:521)
08-12 18:46:04.991: ERROR/AndroidRuntime(730): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
08-12 18:46:04.991: ERROR/AndroidRuntime(730): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
08-12 18:46:04.991: ERROR/AndroidRuntime(730): at dalvik.system.NativeStart.main(Native Method)
08-12 18:46:04.991: ERROR/AndroidRuntime(730): Caused by: java.lang.NullPointerException
08-12 18:46:04.991: ERROR/AndroidRuntime(730): at com.original.sbooks.SBooks.onActivityResult(SBooks.java:111)
08-12 18:46:04.991: ERROR/AndroidRuntime(730): at android.app.Activity.dispatchActivityResult(Activity.java:3595)
08-12 18:46:04.991: ERROR/AndroidRuntime(730): at android.app.ActivityThread.deliverResults(ActivityThread.java:3001)

View 2 Replies View Related

Android :: Back Button Activity

Aug 25, 2010

I was wondering how or if it is possible to exclude activities from the back buttons history list? For example not letting the user back into the Splash Screen?

View 2 Replies View Related

Android :: How To Implement Back Button

Nov 24, 2010

I want to implement back button functionality in my Android Application similar to the back button in the Browser but without using Intents.

I m going to view a sport listview, in that i click football listview , in that i click my favorite player listview, suppose if the user press back button in football listview then i have to diaplay sport listview.

View 1 Replies View Related

Android : What Could Disable The Back Button

Sep 1, 2009

I have a bunch of activities that are launching each other through intents. somehow, i got into a code state where some of the screens the back button (physical button) works, but others it does not.

I didn't do anything intentionally to disable the back button - what could be causing the back button not to work?

View 6 Replies View Related

Android : Activity And Back Button

Nov 2, 2010

on the ui i am having a back button displayed. there are three activities say A,B,C. Activity A is splash screen. Activity B is home screen. Activity C is edit screen. on edit screen only i am having a back button. when the user press that i open the activity B which also contains some sort of http request and response. i want that the previous activity from stack should get displayed? how can i achieve that? i am able to open previous activity on pressing the back button of device? when i press back button on device there doesnt goes any http request? i want to achieve this behaviour when i press the ui back button.

View 2 Replies View Related

Android : Back Button And Last Activity

Aug 17, 2010

My app chains some activities.

if you press the back button, you go back through old activities then you suddenly quit the application !

so I need to show a message like "do you really want to exit" if it's the last activity on stack

I know how to override the back button but i can't figure how to know how many activity are in history

CODE:..................

View 1 Replies View Related

Android : Intercepting The Back Button

Sep 1, 2010

I'm writing an application which will have two Activities, when the user presses the back button on the second activity a dialog should pop up asking the user to confirm the action. So how do I intercept this? I seriously doubt about this coz the backstack is a part of the OS itself. Has anyone found a workaround?

View 2 Replies View Related

Android : Using Notepad Example - Add A Back Button

Sep 27, 2010

I have an activity that calls the

CODE:.........

I would like to add a button to the notes_row.xml that displays at the bottom of the screen "on top of" the actual notes_row allowing the user to still scroll through the list but hit the button if they want. Every time I try to change the layout of notes_row, I get the button on each item in the list. I am pretty new to Android and I think I need to inflate the button somehow so that it is layered in front of the list but doesn't impede the list, how do I go about doing that?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved