星空网 > 软件开发 > 操作系统

Android Intent调用 Uri的使用几种格式

打开百度

Uri uri = Uri.parse("http://www.baidu.com");
 Intent intent =new Intent(Intent.ACTION_VIEW,uri);
startActivity(intent);

打开另一个页面
Intent intent =new Intent(MainActivity.this,Main2Activity.class);
startActivity(intent);
 //拨打电话
Uri uri = Uri.parse("tel:10010");
Intent it = new Intent(Intent.ACTION_DIAL, uri);
startActivity(it);
//权限设置如下
<?<manifest   package="com.gis_luq.activitytest1" >
<uses-permission android:name="android.permission.CALL_PHONE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Main2Activity"
android:label="@string/title_activity_main2" >
</activity>
</application>

</manifest>

传达信息
Intent intent =new Intent(MainActivity.this,Main2Activity.class);

intent.putExtra("yl1","gisoracle");

//用Bundle携带数据
Bundle bundle=new Bundle();
//传递name参数为tinyphp
bundle.putString("yl2", "我爱你桂霞");
intent.putExtras(bundle);
startActivity(intent);

public class Main2Activity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);

//获取Intent携带数据
Intent intent = getIntent();
String index = intent.getStringExtra("yl1");

//用Bundle携带数据
Bundle bundle = getIntent().getExtras();
String data = bundle.getString("yl2");//读出数据

Toast.makeText(this, index + "-" + data, Toast.LENGTH_SHORT).show();
}



原标题:Android Intent调用 Uri的使用几种格式

关键词:Android

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

董加敏:https://www.goluckyvip.com/tag/30675.html
董事长英文翻译:https://www.goluckyvip.com/tag/30676.html
董振国:https://www.goluckyvip.com/tag/30677.html
动态广告:https://www.goluckyvip.com/tag/30678.html
动态搜索广告:https://www.goluckyvip.com/tag/30679.html
奏响爆单狂曲:https://www.goluckyvip.com/tag/3068.html
千岛湖绿城度假酒店的简介:https://www.vstour.cn/a/363185.html
深圳大湾区游轮夜景 深圳大湾区游轮夜景图:https://www.vstour.cn/a/363186.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流