Communication between BroadcastReceiver and Activity – android

You can use observers , like public class MyReceiver extends BroadcastReceiver { public MyReceiver() { } @Override public void onReceive(Context context, Intent intent) { ObservableObject.getInstance().updateValue(intent); } } public class MainActivity extends Activity implements Observer { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ObservableObject.getInstance().addObserver(this); } @Override public void update(Observable observable, Object data) { Toast.makeText(this, String.valueOf(“activity observer … Read more

Android get previous activity

You can use the putExtra attribute of the Intent to pass the name of the Activity. Calling Activity, Intent intent = new Intent(this, Next.class); intent.putExtra(“activity”,”first”); startActivity(intent); Next Activity, Intent intent = getIntent(); String activity = intent.getStringExtra(“activity”); Now in the string activity you will get the name from which Activity it has came.

Display Activity From Bottom to Top

Define an animation in res/anim/slide_in_up.xml: <?xml version=”1.0″ encoding=”utf-8″?> <translate xmlns:android=”http://schemas.android.com/apk/res/android” android:fromYDelta=”100%p” android:toYDelta=”0%p” android:duration=”@android:integer/config_longAnimTime”/> and another at res/anim/slide_out_up.xml: <?xml version=”1.0″ encoding=”utf-8″?> <translate xmlns:android=”http://schemas.android.com/apk/res/android” android:fromYDelta=”0%p” android:toYDelta=”-100%p” android:duration=”@android:integer/config_longAnimTime”/> Then apply these after to call startActivity: Intent i2 = new Intent(main.this, test.class); startActivity(i2); overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); There an introduction to Android animation here which may help you further.

How to use activity indicator view on iPhone?

Create: spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; [spinner setCenter:CGPointMake(kScreenWidth/2.0, kScreenHeight/2.0)]; // I do this because I’m in landscape mode [self.view addSubview:spinner]; // spinner is not visible until started Start: [spinner startAnimating]; Stop: [spinner stopAnimating]; When you’re finally done, remove the spinner from the view and release.

Advantages of using Bundle instead of direct Intent putExtra() in Android

It makes little (if any difference). The code using an additional bundle is slightly heavier (it won’t make any difference in any practical application) and slightly easier to manage, being more general. If one day you decide that – before sending information inside an intent – you want to serialize the data to database – … Read more