-
package com.hk.test;
-
-
import android.app.Activity;
-
import android.app.AlertDialog;
-
import android.content.Context;
-
import android.content.Intent;
-
import android.net.Uri;
-
import android.os.Bundle;
-
import android.provider.MediaStore;
-
import android.telephony.TelephonyManager;
-
import android.util.Log;
-
import android.view.LayoutInflater;
-
import android.view.Menu;
-
import android.view.View;
-
import android.widget.Button;
-
-
public class MainActivity extends Activity {
-
-
@Override
-
protected void onCreate(Bundle savedInstanceState) {
-
super.onCreate(savedInstanceState);
-
setContentView(R.layout.activity_main);
-
-
((Button) findViewById(R.id.select_photo)).setOnClickListener(new View.OnClickListener() {
-
-
@Override
-
public void onClick(View v) {
-
selectPhotoFromAlbum();
-
}
-
});
-
-
((Button) findViewById(R.id.btn_get_phone_info)).setOnClickListener(new View.OnClickListener() {
-
-
@Override
-
public void onClick(View v) {
-
-
AlertDialog mAlertDlg = new AlertDialog.Builder(MainActivity.this).create();
-
mAlertDlg.show();
-
LayoutInflater factory = LayoutInflater.from(getApplicationContext());
-
View view = factory.inflate(R.layout.alert_register_send_pin, null);
-
mAlertDlg.getWindow().setContentView(view);
-
}
-
});
-
-
}
-
-
private void showPhotoInfo() {
-
TelephonyManager telephonyManager = (TelephonyManager) getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
-
String nativePhoneNumber = telephonyManager.getLine1Number();
-
Log.e("hunk", "aaaaaaaaaaaaaa");
-
Log.e("hunk", (nativePhoneNumber.equals("")) + "" + nativePhoneNumber.toString());
-
}
-
-
@Override
-
public boolean onCreateOptionsMenu(Menu menu) {
-
// Inflate the menu; this adds items to the action bar if it is present.
-
getMenuInflater().inflate(R.menu.main, menu);
-
return true;
-
}
-
-
private void selectPhotoFromAlbum() {
-
Intent intent = new Intent(Intent.ACTION_PICK, null);
-
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
-
// Intent intent = new Intent();
-
// intent.setType("image/*");
-
// intent.setAction(Intent.ACTION_GET_CONTENT);
-
Log.e("hunk", "selectPhotoFromAlbum = ");
-
startActivityForResult(intent, 1);
-
}
-
-
@Override
-
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-
-
if (resultCode == Activity.RESULT_OK && requestCode == 1) {
-
Uri uri = data.getData();
-
Log.e("hunk", "uri = " + uri.getPath());
-
}
-
super.onActivityResult(requestCode, resultCode, data);
-
}
-
- }