activity

Android Best Practice on Updating the UI from BroadcastReceiver to a certain activity

When i have a broadcastReceiver say android.intent.action.MEDIA_BUTTON and i want to update the current activity's UI without creating a new activity, is there any good practice on this one? What i know (might not be correct) 1) I can put the BroadcastReceiver in the same class as the activity and call the updateUI function after certa...

Creating a skeleton for a Game Algorithm in Android

Hello. I need some help on the following: I have the following class: public class Game extends Activity {... ...} My questions is: Where and how do I create my View (do I use another class that extends View....) Where and how do I implement the Runnable interface so I would be able to use threads. Where and how do I connect all...

Android - Return to calling Activity

Newbie Question from an iPhone developer. I have called the startActivity(intent) and the new activity loads. How do I go 'back' to the calling activity once a button is pushed. 'Popping' the activity off the stack basically. ...

android open dialogue activity without opening main activity behind it

Im writing a program that offers a quick reply dialog upon receipt of an SMS. However, I am getting an unexpected result. When I receieve an SMS, the appropriate dialog activity comes up displaying the correct phone number and message, however there is a second activity behind it that is the 'default' activity in my program (it is what ...

Android: how do you get a view reference from a class that DOES NOT extend Activity?

Hi, I want to have a class "Utils", that will have several methods used all over my code. For example, I have a top bar with a textview and two ImageButtons that must display different texts and icons on different activities. I find myself writing stuff like this on every activity (TextView) topBarText = (TextView) findViewById(R.id....

Android network problem under screen off

In my application, have 3 threads: 1. main 2. network send 3. network receive Because the application need keep-alive the session, so thread #2 need send a keep-alive packet to server when idle more than 1 minute. If the screen is on all are ok, but under screen off, thread #2 like blocking somewhere, and if I plug-in the USB cable for ...

Apply the Android "Dialog" theme and sizing it properly.

I have an activity that I would like to occur in a dialog. Is there anyway to do this from code, instead of in the manifest? I tried to do this, but it seemed to have no effect. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTheme(R.style.Theme_Dialog); } Also, the activity...

Android - Activity Constructor vs onCreate

I understand that Android Activities have specific lifecycles and that onCreate should be overridden and used for initialization, but what exactly happens in the constructor? Are there any cases when you could/should override the Activity constructor as well, or should you never touch it? I'm assuming that the constructor should never b...

Android: Extending a custom abstract Activity

Hello, I created an abstract Activity which extends the android.app.Activity. Then I created an activity extending my abstract one. [1] Everything is fine with ant, but eclipse showed an error in the manifest saying that my activiy did not exists, so I regenerate the class files and the error in the manifest is gone. But now eclipse s...

How to make notification intent resume rather than making a new intent?

What i have here is a simple webview activity that when loaded it auto displays an ongoing notification. The idea is that people can navigate away from this activity and quickly access it again from any screen they want by pulling down the drop down menu and selecting it. Then when they want they can just close the notification by hittin...

Action before startActivity()

Hi, I'm new in Android development and I've a problem when I create my new activity. I want to use my activity before start it. For example, I have try it: MyActivity menu = new MyActivity(); menu.setXmppreception(reception); Intent intent = new Intent(Screen.this,MyActivity.class); Screen.this.startActivity(intent); But, my "menu" ...

Android Activities and Views

When developing an Android app, is there a rule of thumb for when you should stop changing layouts and instead switch to a new activity? What factors might influence the decision? ...

setContentView - strange behavior if not using R.id.?

In my onCreate method for the first loaded Activity I have: super.onCreate(savedInstanceState); final int splash = R.layout.splash; setContentView(splash); This causes the app to crash. But if I use: super.onCreate(savedInstanceState); setContentView(R.layout.splash); everything is fine. What gives? The only reason I am experimen...

Android: How to shut down the Program completely?

Hello, I have a program with several activities. One can start activity B from clicking on a button in Activity A, and can start C from clicking on a button in B, and so on. In short A->B->C->D->E. If i click the button "Exit" in Activity E, i want to shut down my whole program, in another word, i want to finish all of the activities. H...

Keeping a bitmap in memory with the help of onRetainNonConfigurationInstance()

I have a large bitmap that i would like to keep in memory when the qwerty keyboard is visible. My app is always in landscape, so this is the only configuration change that will cause a reDraw. I heard this is what onRetainNonConfigurationinstance() is for...but cant figure it out. Can someone point me in the right direction? Thanks. ...

Android, how to not destroy the activity when I rotate the device?

I have an app that works only in portrait mode, and I have made the changes in my manifest file for every activity the orientation to be portrait. But when I rotate the device, the activity recreates again. How to not destroy the activity? ...

dynamically lunching activity in android

Hi, i am developing an application where one of my Activity contains a button as "Set as Home Page" . So my problem is that when i will click this button the status will be saved in the shared preference and next time when this application will be opened i want to start this Activity(the Activity which has been set as home page) inst...

Updating views of sub Activities of TabActivity from background process.

I am using a TabActivity (Main) with 3 TabSpecs I am using Intents for the content of the 3 Tabs TabA, TabB, TabC for example. All these tab activities use common data that is stored in SharedPreferences In the Main TabActivity I have an options menu which has a refresh option. @Override public boolean onCreateOptionsMenu(Menu menu) {...

Retain only one copy of an activity on the stack when called from non-activity

How can I make sure I only retain one copy of an activity on the stack when called from non-activity? When called from an activity I can just add the FLAG_ACTIVITY_REORDER_TO_FRONT flag to the Intent, but how can I do this from e.g. a widget or a notification? ...

Run method from extends Activity extends Runnable

I'm trying to call a method from inside a Runnable that is running. It waits for a string to be entered and when it is then depending on the string (the strings act as commands) it calls a method and is supposed to run whats inside it. public class App extends Activity implements Runnable { public void run() { try { Ser...