How to pass Object from Activity A to B ?
import java.util.*;
import android.os.*;
public class Data implements Parcelable {
public int value = 0;
public Data() {}
private Data(Parcel in) {
value = in.readInt();
}
public int describeContents() {
return 0;
}
public void writeToParcel(Parcel out, int flags) {
out.writeInt(value);
}
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
public Data createFromParcel(Parcel in) {
return new Data(in);
}
public Data[] newArray(int size) {
return new Data[size];
}
};
}
Intent intent = new Intent(ActivityA.this, Activity.class);
intent.putExtra("data", data);
startActivityForResult(intent, 0);
Intent i = getIntent();
Data data = (Data) i.getParcelableExtra("data");
20 June 2011
How to choose Email writer and fill in ?
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL, "youremail@domain.com");
i.putExtra(Intent.EXTRA_SUBJECT, "subject");
i.putExtra(Intent.EXTRA_TEXT, "message");
startActivity(Intent.createChooser(i, "Select email application."));
30 Sep 2010
How to open a System Screen ?
startActivityForResult(new Intent(Settings.ACTION_SOUND_SETTINGS), 0);
16 Aug 2010
How to open an URL in a native browser ?
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.google.com/"));
startActivity(intent);
How to make a call ?
String url = "tel:1234567";
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse(url)));
How to go to Dial keyword to make a call ?
String url = "tel:1234567";
Intent callIntent = new Intent(Intent.ACTION_DIAL, Uri.parse(url));
startActivity(callIntent);
No comments:
Post a Comment