Rotation (Android )

package Rotatio.aerdy;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class RotaionActivity extends Activity {
static final int PICK_REQUEST=1337;
Button viewButton=null;
Uri contact=null;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Button btn=(Button)findViewById(R.id.pick);
btn.setOnClickListener(new View.OnClickListener() {

public void onClick(View view) {
Intent i=new Intent(Intent.ACTION_PICK,
Uri.parse(“content://contacts/people”));
startActivityForResult(i,PICK_REQUEST);
}
});

viewButton=(Button)findViewById(R.id.view);
viewButton.setOnClickListener(new View.OnClickListener() {

public void onClick(View view) {
startActivity(new Intent(Intent.ACTION_VIEW, contact));
}
});
restoreMe(savedInstanceState);
viewButton.setEnabled(contact!=null);
}

@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode==PICK_REQUEST) {
if (resultCode==RESULT_OK) {
contact=data.getData();
viewButton.setEnabled(true);
}
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if (contact!=null) {
outState.putString(“contact”, contact.toString());
}
}
private void restoreMe(Bundle state) {
contact=null;
if (state!=null) {
String contactUri=state.getString(“contact”);
if (contactUri!=null) {
contact=Uri.parse(contactUri);
}
}
}
}

Download projectnya di Sini

Advertisements

Published by

jarcode

hello I am jarcode

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s