Intent.使用小结

打电话


Intent callIntent = new Intent(Intent.ACTION_CALL,Uri.parse(“tel:12345678”));
startActivity(callIntent);

权限拒绝后就不能再拨打电话了,6.0后可以加一个权限管理对于这种危险权限

通过一个url跳转到一个网页

    @Override  
    public void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.activity_main);  
        button = (Button)findViewById(R.id.button1);     
        button.setOnClickListener(new MyListener());    
        final Uri uri = Uri.parse("http://weibo.cn/qlyh");  
        intent = new Intent(Intent.ACTION_VIEW,uri);    
        timer = new Timer();  
    }  
    class MyTimerTask extends TimerTask {  
        @Override  
        public void run() {  
            startActivity(intent);  
        }     
    }      
    class MyListener implements OnClickListener {  
        public void onClick(View v) {  
            if(task != null)  
                task.cancel();  
            task = new MyTimerTask();  
            timer.schedule(task,1000);  
        }  
    } 

使用Intent在onReceive中跳转

package com.jack.buttonkeytest;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class MyReceiver extends BroadcastReceiver{

    @Override
    public void onReceive( Context context,Intent intent) {
        final Context c = context;
        new Thread(){
            @Override
            public void run() {
                super.run();
                Intent intent = new Intent(c,ShowActivity.class);
                c.startActivity(intent);
            }
        }.start();
    }
}

推荐阅读:

Intent或持久化存储处理复杂对象

相关文章

Android 如何解决dialog弹出时无法捕捉Activity的back事件 在...
Android实现自定义带文字和图片的Button 在Android开发中经常...
Android 关于长按back键退出应用程序的实现最近在做一个Andr...
android自带的时间选择器只能精确到分,但是对于某些应用要求...