两个App之间的跳转 并传值
两个App之间的传值最主要的是方法是
Intent intent = getPackageManager().getLaunchIntentForPackage("com.example.app2");
其他的传值用Intent完成就行 与activity之间的传值类似
(还可以自定义activity的权限) APP1:
package com.example.app1; import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast; public class MainActivity extends AppCompatActivity implements View.OnClickListener { private Button btn1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); btn1= (Button) findViewById(R.id.btn_app1);
btn1.setOnClickListener(this); } @Override
public void onClick(View v) {
// 通过包名获取要跳转的app,创建intent对象
Intent intent = getPackageManager().getLaunchIntentForPackage("com.example.app2"); if (intent != null) {
// 这里跟Activity传递参数一样的嘛,不要担心怎么传递参数,还有接收参数也是跟Activity和Activity传参数一样
intent.putExtra("value","我是App1里的值");
startActivity(intent);
} else { Toast.makeText(getApplicationContext(), "还没有这个APP", Toast.LENGTH_SHORT).show();
}
}
}
在App2中接收
package com.example.app2; import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView; public class MainActivity extends AppCompatActivity { private TextView tv2;
private Intent intent;
private String value;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); intent = getIntent();
Bundle bundle = intent.getExtras();
if (bundle != null) {
value = bundle.getString("value");
}else{
value="没有接收到App1的值";
} tv2= (TextView) findViewById(R.id.tv2);
tv2.setText(value); }
}
两个App之间的跳转 并传值的更多相关文章
- iOS中两个APP之间的跳转和通信
app间的跳转 一:在第一个app首先要做下面这些操作: 1.在info.plist文件中的Information Property List下添加一项:URL types. 2.点开URL type ...
- iOS - (两个APP之间的跳转)
一个程序若要跳到另一个程序.需要在目标程序的plist文件里面修改: 打开info.plist,添加一项URL types 展开URL types,再展开Item0,将Item0下的URL ident ...
- ios两个app之间跳转,传值的实现
两个APP之间的跳转是通过[[UIApplication sharedApplication] openURL:url]这种方式来实现的. 1.首先设置第一个APP的url地址 2.接着设置第二个AP ...
- 两个APP之间怎么调用《IT蓝豹》
两个app之间怎么调用? (1):通过显示Intent 启动 首先:配置好B app 的action,即AndroidManifest.xml中声明 <intent-filter> ...
- iOS APP之间到跳转,以及热门应用,手机自带到应用跳转
应用之间的跳转 在第一个APP中,做如下操作:1.在info.plist文件中的"信息属性列表"下添加一项:"URL类型"; 2.点开"URL类型&q ...
- 通过AIDL在两个APP之间Service通信
一.项目介绍 [知识准备] ①Android Interface definition language(aidl,android接口定义语言),其目的实现跨进程的调用.进程是程序在os中执行的载体, ...
- app之间的跳转,进入二级界面
功能实现:A跳到B并打开B中指定页面.http://blog.csdn.net/dollyyang/article/details/50325307 点击页面判断是否安装app并打开,否则跳转app ...
- app之间的跳转和传参问题
app 之间跳转和传参: 首先 创建2个app formApp (需要跳转到另外app的项目) toApp(被跳转的项目) 一:在toApp 项目中的操作: 1:创建URLSchemes ...
- 两个App之间调起通信
前言 经常使用一些app的分享功能,比如点击QQ分享,就从app打开(跳转到)QQ,然后分享完之后又回到我们的app,那么这是怎样实现的呢? 假设有这么一个需求,由app1跳转到app2,当app2完 ...
随机推荐
- Aop 中 JoinPoint等对象的用法Api
@Aspect 定义类为切入类 @Pointcut 声明一个切入策略供 @Before @After @ Around @ AfterReturning选择 @Before 被切入方法执行前执行 @A ...
- 19.struts-配置详解.md
目录 1.package name extends abstract namespace 2.action name class method 3.result name type 标签体 <p ...
- http协议以及http1.0和http1.1的区别
header响应头信息: HTTP/1.1 302 FOUND Content-Length: 0 Set-Cookie: sessionid=n3gozvqbjba1zckr7v0ccj6yn7v9 ...
- IDEA导入jar包
http://blog.csdn.net/a153375250/article/details/50851049
- MySQL 5.7 使用原生JSON类型
首先回顾一下JSON的语法规则: 数据在键值对中, 数据由逗号分隔, 花括号保存对象, 方括号保存数组. 按照最简单的形式,可以用下面的JSON表示: {"NAME": " ...
- javase中javax源码下载地址
OracleJDK 和 OpenJDK 源码都可以参考. OpenJDK 源码下载 http://hg.openjdk.java.net/jdk7/jdk7/jdk/file 我主要是想下载 java ...
- jackson支持LocalDate等java8时间
pom文件增加依赖: <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <arti ...
- apache服务器伪静态配置说明
apache服务器伪静态配置说明: 第一种 .如果是多城市版分类并且使用了城市二级域名即(多城市+多域名),请修改apache的配置文件,把以下代码添加到配置文件的最后一行即可,注意把qibosoft ...
- leetcode 链表类型题总结
链表测试框架示例: // leetcodeList.cpp : 定义控制台应用程序的入口点.vs2013 测试通过 // #include "stdafx.h" #include ...
- css3修改滚动条样式
/*滚动条整体样式*/ /*高宽分别对应横竖滚动条的尺寸*/ .content-box::-webkit-scrollbar{ width: 4px; height: 4px; } /*滚动条里面小方 ...