Android :: How Do You Switch Activity Programatically?
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
Aug 26, 2010
I've been experimenting with the Android SDK over the past few days, in readiness to write an App for the store, however I've run across a bit of a problem.
The App I'll be writing requires that the user has a Google account associated with the phone. Retreiving and making use of the Auth token etc was not a problem, however I would like to be able to show the activity that a user would normal reach by going through the menus Settings->Accounts->Add Account.
Now through experimentation I've been able to launch this activity from the shell using the following command. am start -n com.google.android.gsf/.login.AccountIntroActivity
I'm having trouble performing the same action in JAVA using the Intent class.
Would anyone be able to tell me firstly whether or not this can be done via JAVA, and secondly how I could go about it please?
If I have to settle for the Sync Settings screen then I will (this can be achieved through the Settings.ACTION_SYNC_SETTINGS intent), however it'd be quite nice to be able to direct the user straight to the required screen.
View 2 Replies
View Related
Jun 2, 2009
How can I differentiate an android Activity from a SubActivity programatically?
Is there any api for that?
View 1 Replies
View Related
Sep 2, 2010
Is there a way to retrieve Browser's user-agent without having a WebView in activity?
I know it is possible to get it via WebView:
WebView view = (WebView) findViewById(R.id.someview);
String ua = view.getSettings().getUserAgentString() ;
But in my case I don't have/need a webview object and I don't want to create it just for retrieving user-agent string.
View 1 Replies
View Related
Nov 9, 2010
I have a use case in my application, where after certain point, I need to associate an data with an activity. So whenever an intent with an action and the data type is fired, my activity can be opened. I know that it is possible to associate a data type with an activity statically via AndroidManifest.xml.
Is it possible to register the data type for an activity dynamically and programatically?
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
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
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
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
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
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
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
Jan 20, 2010
I have an application I wrote for Android (lat's call it MyMainApp).
My contractor wants me to write another utility (service) to periodically check his website for newer versions of MyMainApp, and if there is one - download it and install.
I know this is handled by the Market app, but my contractor wants to do it in his own utility (he does not want the user to be bothered with the update process).
Of course - the user will be notified and agree to this feature. Can this be done?
View 2 Replies
View Related
Apr 19, 2010
Is it possible to clear a notification programatically?I tried it with the NotificationManager but its not working.Is there any other way i can do it?
View 2 Replies
View Related
Jan 8, 2010
I have a little problem with a ScrollView.I have a layout for an activity which is made with a ScrollView. This scrollview contains two ListViews.<?xml version="1.0" encoding="utf-8"?>
<ListView android:id="@+id/accountsListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:scrollbars="none" />
<ListView android:id="@+id/cardsListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:scrollbars="none" />
</LinearLayout>In onCreate method of my activity I compute ListViews height according there contents.During execution, on activity launch, ScrollView is already scrolled a bit.So I tried, at the end of onCreate to call method scrollTo(0, 0), but it does not change anything.
View 1 Replies
View Related
Jul 10, 2009
I have To set Wall Paper In application by writing the code programmatically. when i press the Grid view Image will get full screen ..... that image i should keep as a wall paper in the android mobile screen how can i do that in programatically. I have done some thing like this ....is it correct or any other way to do it.
CODE:...............
View 3 Replies
View Related
Dec 14, 2009
I want do set size (in px) of dialog based on screen resolution, so I have to set dialog size programatically during runtime.
Dialog layout is defined in xml with all standard views, so it would be nice to have better way to set dialog size than override-in top view's onMeasure(...).
View 1 Replies
View Related
Jul 24, 2009
Are the following actions possible using the latest version of the Android API?:
Temporarily disable sending text messages
Temporarily disable receiving text messages
*Ideally, I would intercept them and queue them up for later delivery.
Temporarily disable incoming calls except from certain phone numbers
Temporarily disable outgoing calls except to certain phone numbers
View 1 Replies
View Related
Apr 6, 2010
How do we set the input type for an EditText programatically? I'm trying:
mEdit.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
it doesn't seem to have any effect.
View 2 Replies
View Related
Jun 29, 2010
Is it possible to remove an application programatically? If so, shall I look at the package manager for that or is there an example some place? When a package is installed, I believe there is a broadcast message to the system saying that. Is it possible to capture that broadcast message?
View 6 Replies
View Related
Sep 4, 2010
I have a FrameView that's created in my XML layout, and in my code, I'm trying to create a series of new ImageViews and add them as children of this FrameView. The ImageViews are small, only about 15 pixels square, and I want them to show up in various positions around the FrameView (I'm trying to implement what looks like a radar screen). I'm able to create them and add them just fine, and they show up on the screen.
However, when I try to set their margins, it doesn't seem to have any effect. No matter what I set, all the ImageViews show up in the top left corner of the FrameView, as opposed to offset by the appropriate margins. My XML layout is listed below, along with the code that generates the child views. Am I doing something wrong? How can I get the margins to show up properly? Or is there a better way to do this than by using margins.
XML:
CODE:....................
Java:
CODE:...............................
View 1 Replies
View Related
Feb 13, 2010
I'm writing a simple caesar-encryption-activity. Two EditTexts on screen, one clear-text, one crypted.
Here's an example for the crypted EditText - the cleartext one is similar.
CODE:...................
Now when entering cleartext I have an TextChangedListener running that programatically crypts and fills that crypto-EditText. So far, so good.
When the cleartext entered gets really long, the cleartext-EditText scrolls with my imput, but the crypto-EditText stays at the top of the text. I'd really like the crypto-EditText to scroll so that it always shows the bottom line of its content.
How can that be done, preferably from the onTextChanged()-Method of the TextWatcher?
View 2 Replies
View Related
May 31, 2010
How can we programatically push our app to run in background? I am doing one browser app. and when I am directly launching my application and clicking back key . It will show in the list of background running process.At this time Category is "CATEGORY_LAUNCHER" but at the same time if we try to run same app via third party app.and then clicking back key,its not showing in the list of background running process.Here the Category is "CATEGORY_BROWSABLE".and its not displaying in the list of running process.I noticed that the same behaviour in default android browser. But is their any way to make my app to run in background by clicking back key without killing my application?
View 6 Replies
View Related
Aug 6, 2009
In menu.xml you can specify an icon:
CODE:.................
Whereas in code you create entries thus:
CODE:........
How in the code version do you specify the icon please?
View 2 Replies
View Related