Chinaunix首页 | 论坛 | 博客
  • 博客访问: 248432
  • 博文数量: 33
  • 博客积分: 246
  • 博客等级: 二等列兵
  • 技术积分: 918
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-31 16:37
文章分类

全部博文(33)

文章存档

2014年(4)

2013年(7)

2012年(22)

分类: Android平台

2014-01-06 10:13:49


  1. package com.hk.test;

  2. import android.app.Activity;
  3. import android.app.AlertDialog;
  4. import android.content.Context;
  5. import android.content.Intent;
  6. import android.net.Uri;
  7. import android.os.Bundle;
  8. import android.provider.MediaStore;
  9. import android.telephony.TelephonyManager;
  10. import android.util.Log;
  11. import android.view.LayoutInflater;
  12. import android.view.Menu;
  13. import android.view.View;
  14. import android.widget.Button;

  15. public class MainActivity extends Activity {

  16.     @Override
  17.     protected void onCreate(Bundle savedInstanceState) {
  18.         super.onCreate(savedInstanceState);
  19.         setContentView(R.layout.activity_main);

  20.         ((Button) findViewById(R.id.select_photo)).setOnClickListener(new View.OnClickListener() {

  21.             @Override
  22.             public void onClick(View v) {
  23.                 selectPhotoFromAlbum();
  24.             }
  25.         });

  26.         ((Button) findViewById(R.id.btn_get_phone_info)).setOnClickListener(new View.OnClickListener() {

  27.             @Override
  28.             public void onClick(View v) {

  29.                 AlertDialog mAlertDlg = new AlertDialog.Builder(MainActivity.this).create();
  30.                 mAlertDlg.show();
  31.                 LayoutInflater factory = LayoutInflater.from(getApplicationContext());
  32.                 View view = factory.inflate(R.layout.alert_register_send_pin, null);
  33.                 mAlertDlg.getWindow().setContentView(view);
  34.             }
  35.         });
  36.         
  37.     }

  38.     private void showPhotoInfo() {
  39.         TelephonyManager telephonyManager = (TelephonyManager) getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
  40.         String nativePhoneNumber = telephonyManager.getLine1Number();
  41.         Log.e("hunk", "aaaaaaaaaaaaaa");
  42.         Log.e("hunk", (nativePhoneNumber.equals("")) + "" + nativePhoneNumber.toString());
  43.     }

  44.     @Override
  45.     public boolean onCreateOptionsMenu(Menu menu) {
  46.         // Inflate the menu; this adds items to the action bar if it is present.
  47.         getMenuInflater().inflate(R.menu.main, menu);
  48.         return true;
  49.     }

  50.     private void selectPhotoFromAlbum() {
  51.         Intent intent = new Intent(Intent.ACTION_PICK, null);
  52.         intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
  53.         // Intent intent = new Intent();
  54.         // intent.setType("image/*");
  55.         // intent.setAction(Intent.ACTION_GET_CONTENT);
  56.         Log.e("hunk", "selectPhotoFromAlbum = ");
  57.         startActivityForResult(intent, 1);
  58.     }

  59.     @Override
  60.     protected void onActivityResult(int requestCode, int resultCode, Intent data) {

  61.         if (resultCode == Activity.RESULT_OK && requestCode == 1) {
  62.             Uri uri = data.getData();
  63.             Log.e("hunk", "uri = " + uri.getPath());
  64.         }
  65.         super.onActivityResult(requestCode, resultCode, data);
  66.     }

  67. }

阅读(1879) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~