Android :: Switch Back To Previously Selected Tab After Activity Is Recreated?
Jun 13, 2010
In my TabActivity the user may be asked to switch to browser activity for OAuth phase, and if the phase takes too much time, my activity will be killed. After the user switches back to my activity, its onCreate() method is invoked again and tabs are recreated.
So I would like to know if there is any simple way to switch back to previous tab, and keep the tab as what it was. For example, one of the tab views contains a ViewSwitcher child, and I want to switch back to the switched view after recreating the activity.
View 3 Replies
Feb 19, 2010
Is there anyway to go back to a previously launched Activity while running an Instrumentation test? Currently, when I use sendKeyDownUpSync( KeyEvent.KEYCODE_BACK);, this forces my test to exit, rather than go back to the previous Activity.
View 2 Replies
View Related
Sep 30, 2009
I have a flow A->B->C->D where A desires some information that is obtained by D. B, C, and D propagate the data back through the flow using setResult(RESULT_OK, data) and finish(). All intents in A, B, and C are started with startActivityForResult. However, if B is reclaimed by Android and forced to call onCreate again after C finishes onActivityResult in B is never called and the data never makes it back to A. Is there a way I can be sure that onActivityResult will be called?
View 5 Replies
View Related
Sep 10, 2010
I am using an AsyncTask to fetch the ring tone for a contact when my application starts, it works fine until after my Activity closes a couple of times during the AsyncTask, after this happens the AsyncTask will only ever get to onPreExecute() and never doInBackground, so I can never fetch the ringtone then until either a force stop or device restart.
Why this might be happening? Why the AsyncTask would get to onPreExecute but then never run doInBackground()?
Here is my code: (Following the Shelves source code)
CODE:.....................
And onAddRingtone() is used in onCreate and onCancelRingTone() is used in onDestroy() as well as where you can see if in the code above. I have spent 3 days on this and I haven't been able to find a solution? Am I taking the wrong approach? Using cancel wrong? Is there a bug?
View 1 Replies
View Related
Jul 30, 2009
I have a notification that starts my activity and passes a messages using the intent's putExtra() function. The message is then displayed to the user in the activity's onCreate function. When the application is restarted due to a orientation change, the message is shown again as it is still in the intent's bundled data.
How can I remove the extra data?
I tried the following:
Bundle bundle = getIntent().getExtras();
if (bundle.getBoolean("showMessage")) {
// ... show message that is in bundle.getString("message")
// remove message
bundle.remove("showMessage");
}
But the message will still be shown after the orientation changed, seems like the intent used is not the one I changed, but the original one. The only workaround I found is to save the showMessage additionally in onSaveInstanceState(). Is there another way? Or is this the way to go?
View 2 Replies
View Related
May 3, 2009
I need some help using ListActivity. The API provides "onListItemClick" which you can override and is called when user selects an item in the list.
However I want the same type of functionality when an item in the list is selected. So as soon as user highlights something in the list I want my application to do something (like play a preview). I dont want to wait for user to select the button.
View 2 Replies
View Related
Apr 18, 2013
I have to develop one android application.
Here is the scenario:There are many images in a linearlayout. When selected, the layout should be displayed with another(gradient_bg_hover.xml) background. This works well now.
Now, I would like that when I open a new activity and come back to this one, the last selected layout should still be the highlighted one (with the (gradient_bg_hover.xml) background).
Now i have used below code for highlighting the image when pressed:
[HIGH]
LinearLayout ar = new LinearLayout(this);
ar.setOrientation(LinearLayout.VERTICAL);
ar.setPadding(3, 3, 3, 3);
ar.setLayoutParams(artiLayoutParams);
ar.setGravity(Gravity.CENTER);
ar.setBackgroundColor(Color.parseColor("#666666")) ;
[Code]...
In OnClick function i have wrote the below code:
[HIGH]
private OnClickListener mArticleClick = new OnClickListener()
{
@Override
public void onClick ( View v )
{
int object = v.getId();
v.setSelected(true);
[Code]...
Here i have to clicked one item means it is go to next activity.afterthat i have clicked back button means the selected item is stay on highlighted with another background.afterthat i have selected another item means its go to next activity.now i have to click back button means these item only highlight with background....but the pervious item also highlighted....
I wish to need the o/p like :
The last selected item only highlighted after click the back button...
So i have used sharedpreferences :
I have declared int prevPosition = -1; globally...
[HIGH]
ar = new LinearLayout(this);
ar.setOrientation(LinearLayout.VERTICAL);
ar.setPadding(3, 3, 3, 3);
ar.setLayoutParams(artiLayoutParams);
ar.setGravity(Gravity.CENTER);
[Code]...
In Onclick method:
[HIGH]
private OnClickListener mArticleClick = new OnClickListener()
{
@Override
public void onClick ( View v )
{
int object = v.getId();
[Code]...
But my background color is not staying after press the back button...
View 1 Replies
View Related
Sep 15, 2010
So I made LP my default launcher by checking the "make default" box which of course disables the choice. I'd like to switch back to ADW. Without un installing LP is there a way to switch back to ADW?
View 1 Replies
View Related
Feb 17, 2010
I'm currently working on an application, designed around a TabActivity.Tab1 has a button and I would like when the user click it, it switches to Tab2.
View 10 Replies
View Related
Sep 22, 2010
In android, I have a TabActivity with 2 tabs and each tab has it own activity (say ActivityA and ActivityB). When I am on ActivityA, and I click on ActivityB's tab, how does the ActivityA knows it is no longer the active Tab?
View 1 Replies
View Related
Jan 26, 2009
I have an application with contains multiple activities. The main activity will start the others ( use startActivity() ) depends on user event, when an activity close, it calls finish() and return back to main activity. It appears to behavior like that.
However, the "problem" I see is main activity's onCreate function is called every time. I think the the main activity should be placed in the activity stack and simply push to front when others exit, therefore only onResume, onStart are called. Is there some flag I need to set or I misunderstand the activity behaviro?
In child activity, besides calling finish() or startActivity for main activity, what is other way to move main activity to front?
View 2 Replies
View Related
Mar 3, 2010
example scenario is: from login screen - main screen - then when i clicked a hide button the app will go to home screen, and when im going to click the app again the main screen would be called.
View 2 Replies
View Related
Mar 29, 2010
Currently I have a TabHost implemented with 3 tabs each containing a separate activity. My question is how do I switch between tabs from within one of the activities that is located inside the tab host. I've looked everywhere and have been unsuccessful in finding a real answer to this problem.
View 4 Replies
View Related
Aug 28, 2010
It seems like every example I can find of switching between Activity's involves creating an Intent and passing in the context of a View via an OnClickListener associated with a button.But what if you just decide you need to switch Activity's? In my case, a Preference value is causing an Activity switch. How do you create an Intent that can cause an Activity switch without an associated OnClickListener?
View 4 Replies
View Related
Jul 24, 2010
This post probably shows my ignorance of Android coding, but here goes. I have a sample app I am developing which starts by extending Activity. I have a main.XML layout which works great. On a button click from the main layout I'd like to load a ListView. I think I understand how to use ListView and seed data into it. I have created a new layout which contains this ListView. I am confused, however, how I switch from a regular Activity to a ListActivity so I get the convenience methods like setListAdapter()? Should I be starting with a ListView, and then drawing the other view on top once the app starts by inflating the layout and using it? If not, how do I create a ListActivity object inside my app, and where should I create that? If you have a sample application or tutorial that shows how to do this, I would appreciate it.
View 2 Replies
View Related
Jan 22, 2009
I have a main class derived from Activity, I need a ListActivity (displayed when the "menu" button is clicked). How can I proceed. I don't understand how I can switch from one to the other?
View 3 Replies
View Related
Sep 1, 2010
I have a singleton in an activity. When I end my application (like pressing back button), and start it again after some time, the singleton is not recreated, but is holding previous state. Singleton is not destroyed if the application is destroyed? Do I have to null its static members in onDestroy() to avoid memory leak.
View 1 Replies
View Related
Oct 27, 2010
public class TestCamera extends Activity implements SurfaceHolder.Callback, View.OnClickListener {
Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
// TODO Auto-generated method stub
picture = data } };
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_DPAD_CENTER)) {
mCamera.takePicture(null, null, mPictureCallback);
return true; }
return super.onKeyDown(keyCode, event); }
@Override
public void onClick(View view) {
switch(view.getId()) {
case R.id.camera:
picture_intent = new Intent(this, PictureViewer.class);
picture_intent.putExtra("picture", picture);
mCamera.startPreview();
startActivity(picture_intent); } }
In the emulator, the program behaves like it should. However, when I put this application on my phone (Nexus one), it doesn't switch to the new Activity when I touch the screen after I take a picture. If I touch the screen without taking a picture, it switches to the new activity. I can't figure out why my phone won't switch to the new Activity after taking a picture.
View 2 Replies
View Related
Nov 24, 2010
does anybody knows how to launch a new activity with rotation animation.That I would like to know if there is a way to do the same but instead of image, i will be activity (whith new layout).
View 1 Replies
View Related
Sep 1, 2010
I am in a situation like, i have custom list view. One button, with listitems. When i click the button, i need to switch the activity. But the calls, startActivityForResult(myIntent, 0); --> is a non static call. I couldnt initiate this function in onClickLIstener() for the button. Dont know how to proceed with this situation ? Can anyone help me out with this.? Code...
View 4 Replies
View Related
Dec 4, 2009
In android Email app, when I first launch it, it will shows me the 'account setup wizard' activity. But when I launch the Email app(after the account is set) again, it wont' show the 'account setup wizard' activity, it will show the 'Folder list activity ' instead.
How can it does the main activity switch (depends on the email account setup)?
View 2 Replies
View Related
Dec 8, 2009
I have created a TabHost and in 1 of the tab, I have added the content using
mTabHost.addTab(mTabHost.newTabSpec("tab1")
.setIndicator(getString(R.string.dialerIconLabel),
getResources().getDrawable(R.drawable.ic_tab_dialer))
.setContent(intent));
Is it possible for me to switch the content's activity programatically after I called 'addTab of TabHost'?
View 1 Replies
View Related
Nov 17, 2010
I have an activity (say activity A) which displays video using a mediaplayer, rendered in a surfaceview.
The use case is to pause the video, start another activity (say activity B), then come back to activity A.
Activity A is stopped but not destroyed when going to B, which is good.
The surface view (since not visibile) IS destroyed (as observed from the notification callbacks). When coming back to activity A, and restarting the mediaplayer using start(), the media player does play back the audio, but video is not seen. Errors like this one are output on Logcat:
CODE;......
Unfortunately, using the new instance of SurfaceHolder as provided by surfaceCreated() doesn't help (i.e. provides the same error).
I have read in various posts a solution would be to reset the mediaplayer and restart it completely, however it is not efficient, as the end user would have to wait for the whole player preparation cycle + seekTo last position within the stream.
As shown with the fact the audio plays back, it should be a matter of plumbing between the the video decoder and the new surfaceholder/view.
What should be the best solution (best = fastest) to resume video playback when resuming the activity?
View 3 Replies
View Related
Jul 23, 2010
I've met a very strange issue that my app will crash if user first switch to landscape, then back to portrait. I found that Activity.setContentView() will throw an inflate exception. It said:
android.view.InflateException: Binary XML file line #29: Error inflating class <unknown>
This crash will happens on Android 1.6/2.1/2.1-update1, but doesn't happen in 2.2 Froyo. In Froyo, everything works fine. If the XML I used is invalid, it should happens every time when I try to inflate. But why it's okay on the first time of running and switching to landscape? This also only happens on some devices. For example, there two HTC G1 with same software installed on it and has the same configuration, one has this issue and the other one works fine.
View 7 Replies
View Related
Feb 19, 2010
I have a basic calculator app I'm making. Two activities, the main one and ResultView.
I've made it where I click a button on activity A to go to activity B. The log says activity B is started and "displayed" successfully, the title for the new activity loads, but the body does NOT show. I added a simple Text view with static text.. see the result.xml at the bottom. I also tried inserting information programmatically, but that didn't do.
When I debug the program, I tried putting breakpoints as the activity is called with startActivity() as well as on the first line of the onCreate method within the ResultView class (my activity "B") but the program never hits the second breakpoint. In fact, it looks as if Looper.class is called in the end.
This bit of code is placed in the button handler on acitivity A:
CODE:........
The activity is in the manifest, within the "application" tag:
CODE:....................
If more info is needed, let me know...in short, "HELLO WORLD" does not display at all.
View 2 Replies
View Related
Aug 28, 2010
I have an app that uses a database. At startup I check to see if my tables are missing and if so I create them. Works great.
I've noticed that if I "adb uninstall" then the next time I run my app the tables are created again (this is what I need), but what about when updating through the marketplace?
I'm in the process of releasing an update, and I've made major changes to the tables. I'd like it if the tables were completely wiped and re-created, in fact my app needs this to happen. If someone updates and has the old tables then there will be a force close. Does anyone know the specifics of this scenario?
My tables are only for lookup, I store no user data so I dont really care about losing data on the updates.
Of course I know an option is to use some type of "version" table and check to see if I need to manually drop and create, but I was wondering if that was even needed.
View 1 Replies
View Related
Nov 4, 2010
I am on my first Android application and I am on a timeline so details and examples will be useful since my knowledge is still minimal. I want my first screen to present the user with a list of activities to choose from. In my situation it is a recipe app where the user first chooses the type of food, such as, Beef, Chicken, or Pork. I want the application to launch an activity depending on the list item that the user clicked on. I am not sure if I should use a list view, a text view, a scroll view, a list activity, an activity group...
View 1 Replies
View Related
Nov 18, 2010
I am working on an application where I need to go to the next Screen form the Main Actvity when I Click on the Image Button of the Main Activity Screen. I had searched a bit on Net regarding this and found something like the OnClickListener method. I am still stuck for what exactly I want to do actually.
View 3 Replies
View Related
Jun 25, 2010
I tried to switch from Launcher Pro back to Sense and it just keeps force closing HTC Sense.
View 2 Replies
View Related
Sep 4, 2010
I've noticed more than once my Evo will not switch back to the Sprint network after roaming. At my house I get full signal so it's not a quality issue. It just seems like the phone won't switch back! If I reboot the phone all is ok again.
View 8 Replies
View Related