Tag: android-activity

Android – How to change texts in the preferences activity dynamically?

Hello fellow programmers, I have a little problem with Preferences activity. http://developer.android.com/reference/android/preference/PreferenceActivity.html I’ve got just one preference category and a listPreference: <?xml version=”1.0″ encoding=”utf-8″?> <PreferenceCategory android:title=”@string/basic_settings” > <ListPreference android:defaultValue=”70″ android:entries=”@array/listArray” android:entryValues=”@array/listValues” android:key=”updates_interval” android:persistent=”true” android:summary=”@string/SOME_SUMMARY” android:title=”@string/SOME_TITLE” /> </PreferenceCategory> I need to have the selected value (the default one or the user defined one) written in the […]

Get activity instance

Excuse me for simple question,I’m completely beginner java and android developer. How I can get the instance of Activity in setCameraDisplayOrientation when surfaceChanged is called? public class MyActivity extends Activity { private Camera mCamera; private CameraPreview mPreview; public final int cameraId = 0; public Activity activity = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); […]

Can I force the Android Back button to go two steps back in the Activity stack?

I know that I can override the onKeyDown method, but I want Back to do it’s thing, just twice!

Switching between Fragments in a single Activity

I want to create an Activity which shows a sort of menu a user can go through. By clicking an item, a new screen is shown, allowing the user more options (wizard-like). I wanted to implement this using Fragments, but it’s not working for me. Right now I have: main.xml: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” […]

Start Activity with Button Android

Ive got a problem. I want to open an Activity with a Button but it crashes all the time. So I created 2 Classes and A Button. But it keeps crashing. Class is activity_home class() and second is schedule_act() class. activity_home class: package my.action.bat; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; public […]

To fragment or not to fragment?

As I’ve started to adopt Fragments more and better but also as Fragments functionality is increased (Fragments in Fragments, MapFragments) I’m starting to reach a point where I need to define when I should make a new View/Action as a Fragment or as an Activity? An Activity is defined as: An activity is a single, […]

How to list all activities exposed by an application?

I think that it should be possible to get all the activities from ‘third-party’ application, described in the manifest file. I can’t figure out how. for example: List<Activity> aList = packManager.getActivitiesForPackage(“package.name”); thanks in advance!

Android implementation of lifecycle methods can call the superclass implementation after doing any work?

In the Android documentation we have: Note: Your implementation of these lifecycle methods must always call the superclass implementation before doing any work… But I have seen cases where the code is placed after the superclass method, especially for methods like onPause(), onStop(), onDestroy(), for example: @Override protected void onPause() { LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver); super.onPause(); } http://www.vogella.com/articles/AndroidBroadcastReceiver/article.html#ownreceiver_localbroadcastmanager […]

Android: How to pass the data to sub-activities?

The main activity includes some variables with set values. I created a sub-activity with the form which has to be filled with the data from main activity so I guess the data have to be passed to the sub-activity when it starts. Does anyone know how to pass the variable values to the sub-activity from […]

How to finish parent activity from child activity

I am new to Android development. I have created a main Activity (->A), which has 4 buttons. One of the 4 buttons is the EXIT-button. I start another activity (->B), on click of the EXIT-button. This opens ‘B’Activity via an intent from ‘A’Activity. Activity ‘B’ contains – Do you want to exit? Yes-Button & No-Button. […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.