个人Android笔记(一)

阅读更多
1、Linkify规则:Linkify.addLinks(tv,Linkify.WEB_URL|Linkify.PHONE_NUMBERS)

2、打电话:Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:" + et.getText()));

3、拨号:Intent intent = new Intent(Intent.ACTION_DIAL);

4、getListView().setTextFilterEnabled(true);//List中允许使用a,b等键盘字母进行快速查询

5、完全退出程序:Android2.2版本
Intent startMain = new Intent(Intent.ACTION_MAIN);
       startMain.addCategory(Intent.CATEGORY_HOME);
       startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
       startActivity(startMain);
       System.exit(0);//退出程序
Android2.2以下版本
1、在配置文件中加入权限:
   
  2、ActivityManager am = (ActivityManager)getSystemService (Context.ACTIVITY_SERVICE);
    am.restartPackage(getPackageName());

6、Activity无标题全屏模式
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

7、窗口类型的activity
android:theme = "@android:style/Theme.Dialog"

8、拆分短信,发送(直接发送出去,不调用系统的发送短信界面)
SmsManager smsManager = SmsManager.getDefault();
PendingIntent pi = PendingIntent.getBroadcast(SmsActivity.this, 0, new Intent(), 0);
  if(et_content.length() > 70){
//将大于70个字符的内容拆分为多条短信
        ArrayList contents = smsManager.divideMessage(content);				
	for(String sms:contents){
        //第一个参数destinationAddress:目标地址
         //第二个参数scAddress:短信中心
         //第三个参数text:要发送的短信内容
         //第四个参数sentIntent:发送方是否发送成功的标识
         //第五个参数deliveryIntent:接收方是否发送成功的标识
         smsManager.sendTextMessage(et_number.getText().toString(), null, content,null, null);
       }
    }else{
      smsManager.sendTextMessage(et_number.getText().toString(), null, content,null, null);
    }


9、调用系统的短信界面发送短信
Intent intent = new Intent(Intent.ACTION_SENDTO,Uri.parse("smsto:" + "13354022687"));
    intent.putExtra("sms_body", "hello,this is for test");
    startActivity(intent);



10、设置activity的背景色
  (1)xml中实现:
   android:background="@drawable/white"
  white色定义在res/values中
  (2)程序中实现:
 
Resources resource = getBaseContext().getResources();
  Drawable hippoDrawable = resource.getDrawable(R.drawable.white);
  TextView tv = (TextView)findViewByID(R.id.text);
  tv.setBackground(hippoDrawable);

你可能感兴趣的:(Android,Web,XML)