-
2021-06-04 15:31:22
private static final String SCHEME = "package";
/**
* 调用系统InstalledAppDetails界面所需的Extra名称(用于Android 2.1及之前版本)
*/
private static final String APP_PKG_NAME_21 = "com.android.settings.ApplicationPkgName";
/**
* 调用系统InstalledAppDetails界面所需的Extra名称(用于Android 2.2)
*/
private static final String APP_PKG_NAME_22 = "pkg";
/**
* InstalledAppDetails所在包名
*/
private static final String APP_DETAILS_PACKAGE_NAME = "com.android.settings";
/**
* InstalledAppDetails类名
*/
private static final String APP_DETAILS_CLASS_NAME = "com.android.settings.InstalledAppDetails";
/**
* 调用系统InstalledAppDetails界面显示已安装应用程序的详细信息。 对于Android 2.3(Api Level
* 9)以上,使用SDK提供的接口; 2.3以下,使用非公开的接口(查看InstalledAppDetails源码)。
*
* @param context
*
* @param packageName
* 应用程序的包名
*/
public static void showInstalledAppDetails(Context context, String packageName) {
Intent intent = new Intent();
final int apiLevel = Build.VERSION.SDK_INT;
if (apiLevel >= 9) { // 2.3(ApiLevel 9)以上,使用SDK提供的接口
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts(SCHEME, packageName, null);
intent.setData(uri);
} else { // 2.3以下,使用非公开的接口(查看InstalledAppDetails源码)
// 2.2和2.1中,InstalledAppDetails使用的APP_PKG_NAME不同。
final String appPkgName = (apiLevel == 8 ? APP_PKG_NAME_22
: APP_PKG_NAME_21);
intent.setAction(Intent.ACTION_VIEW);
intent.setClassName(APP_DETAILS_PACKAGE_NAME,
APP_DETAILS_CLASS_NAME);
intent.putExtra(appPkgName, packageName);
}
context.startActivity(intent);
}
更多相关内容 -
android Web跳转到app指定页面并传递参数实例
2021-01-03 13:33:11下面将实现 Web跳转到app指定页面并传递参数 总结 先看效果图: h5页面代码: <!doctype html> <html> <head> <meta charset=utf-8> <meta name=viewport content=initial-scale=1.0, ... -
Android如何通过scheme跳转界面
2020-08-29 21:56:00Android如何通过scheme跳转界面,这篇文章就为大家介绍了Android通过scheme跳转界面的方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 -
Android实现H5点击打开app或跳转指定界面
2021-05-26 09:38:53Android实现H5点击打开app或跳转指定界面本文原创,转载请注明出处。欢迎关注我的 简书。安利一波我写的开发框架:MyScFrame喜欢的话就给个Star场景H5界面中的入口有时候为了方便用户在H5界面上直接下载app或者打开...Android实现H5点击打开app或跳转指定界面
本文原创,转载请注明出处。欢迎关注我的 简书。
安利一波我写的开发框架:MyScFrame喜欢的话就给个Star
场景
H5界面中的入口
有时候为了方便用户在H5界面上直接下载app或者打开手机app,我们会在H5界面上添加一个按钮,点击按钮可以实现下载或者打开app的功能。关于下载功能这里不做叙述,这里主要讲述打开app并跳转到指定界面的业务如何实现。
规则
://?
这样写可能大家看不大懂,没事,我们接着往下看。
关键代码
1.AndroidManifest中加入intent-filter:
android:name=".view.login.WelcomeActivity">
我们要在拥有android:name="android.intent.action.MAIN参数的界面下新增一个intent-filter
至于为什么要在android:name="android.intent.action.MAIN参数的界面下新增而不是其他界面,这应该不需要多做叙述了吧,想必android:name="android.intent.action.MAIN参数的作用大家都懂。
2.参数描述:
android:scheme="android" 用来辨别启动的app
android:host="h5" 可以当成是一个域名,这边建议使用应用的包名
android:pathPrefix="/open" 参数路径前缀
如果你要传递type=1,id=7这两个参数的话,在H5中展示效果应该是:
打开看看
3.接收参数:
Intent intent = getIntent();
String action = intent.getAction();
String type= null;
String id = null;
if (Intent.ACTION_VIEW.equals(action)) {
Uri uri = intent.getData();
if (uri != null) {
type = uri.getQueryParameter("type");
id = uri.getQueryParameter("id ");
}
}
4.建议:
实际开发过程中,如果直接从WelcomeActivity跳转到指定界面的话,返回的时候可能会直接退出应用(我开发的若干个应用中WelcomeActivity界面在跳转其他界面后都会直接关闭。)如果是在指定页面的返回操作中去启动HomeActivity的话,可能效果上不是很理想,因为大多数应用的首页都是相对复杂的,初始化操作都会比较耗时。
所以,我的个人建议是通过发送EventBus粘性事件给首页,然后在首页里面做相对应的业务跳转逻辑,这样就不影响正常的业务逻辑,而且改动起来也简单一些。
5.其他参考资料
欢迎大家留言指出我的不足。
-
Android如何跳转到应用商店的APP详情页面
2021-01-20 10:05:11* 启动到应用商店app详情界面 * * @param appPkg 目标App的包名 * @param marketPkg 应用商店包名 ,如果为则由系统弹出应用商店列表供用户选择,否则调转到目标市场的应用详情界面,某些应用商店可能会失败 */ ... -
html链接打开app并跳转至某个指定界面
2018-08-08 14:10:53html点击链接打开app并跳转至指定的界面;...如果未登录,则先保存要跳转的界面数据然后到登录界面登录成功回来会自动跳转到需要跳转的界面;这里MainActivity的启动模式为singleTask,需要注意onNewIntent方法 -
Android之APP跳转权限设置界面
2020-05-27 10:43:55说明:这里为特殊情况,因为我们开发外卖平台,很多骑手不懂APP使用,安装APP时会拒绝一些权限导致APP使用不正常,这里拿骑手APP为例,需求是进入APP提示骑手是否权限都开启了,查看跳转设置权限界面,如下图: ...说明:这里为特殊情况,因为我们开发外卖平台,很多骑手不懂APP使用,安装APP时会拒绝一些权限导致APP使用不正常,这里拿骑手APP为例,需求是进入APP提示骑手是否权限都开启了,查看跳转设置权限界面,如下图:
一:实现跳转效果图:
二:实现代码
Intent intent = new Intent(); intent.setAction(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setData(Uri.parse("package:" + this.getPackageName())); startActivity(intent);
-
android 跳转到应用通知设置界面的示例
2020-08-29 03:16:52本篇文章主要介绍了android 跳转到应用通知设置界面的示例,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧 -
Android 中按home键和跳转到主界面的实例代码
2020-08-30 22:44:59本文通过实例代码给大家分享Android 中按home键和跳转到主界面的方法,非常不错,具有参考借鉴价值,需要的朋友参考下吧 -
Android点击按钮跳转界面
2022-01-11 13:15:38思路就是创建两个布局文件,创建...import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageButton; import androidx.appc思路就是创建两个布局文件,创建两个activity文件,布局文件和activity要一一对应
第一个activity
package com.example.app5; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageButton; import androidx.appcompat.app.AppCompatActivity; public class Login_Activity extends BaseActivity { ImageButton imageButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login); imageButton=findViewById(R.id.button_login); imageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(); intent.setClass(Login_Activity.this,Register_Activity.class); startActivity(intent);//重要的是在这里,设置按键监听,设置跳转的界面 } }); } }
第一个activity对应的布局文件
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@mipmap/background_login"> <ImageButton android:id="@+id/button_login" android:layout_width="114dp" android:layout_height="114dp" android:layout_marginTop="549dp" android:layout_marginLeft="170dp" android:src="@mipmap/login"/> <ImageButton android:id="@+id/button_login2" android:layout_width="114dp" android:layout_height="114dp" android:layout_marginTop="549dp" android:layout_marginLeft="170dp" android:src="@mipmap/login"/> </LinearLayout>
第二个activity随意吧,里面不放东西也可以的
package com.example.app5; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.provider.ContactsContract; import android.util.Log; import android.view.View; import android.widget.Button; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import com.example.app5.data.Login; import com.google.gson.Gson; import java.io.IOException; import java.nio.charset.Charset; import java.util.Date; import okhttp3.Call; import okhttp3.Callback; import okhttp3.FormBody; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; public class Register_Activity extends BaseActivity { Button button_Register; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login_password); button_Register = findViewById(R.id.register_button); button_Register.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getData(); Intent intent=new Intent(); intent.setClass(Register_Activity.this,MainActivity.class); startActivity(intent); } }); }}
第二个activity对应的布局文件
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <EditText android:layout_width="match_parent" android:layout_height="46dp" android:hint="请输入账号" android:id="@+id/edittext1" android:textSize="16sp" android:background="@drawable/yuanxing" android:layout_marginTop="48dp" android:layout_marginLeft="35dp" android:layout_marginRight="35dp" /> <EditText android:layout_width="match_parent" android:layout_height="46dp" android:hint="请输入密码" android:id="@+id/edittext2" android:textSize="16sp" android:layout_marginTop="10dp" android:background="@drawable/yuanxing" android:layout_marginLeft="35dp" android:layout_marginRight="35dp"/> <Button android:layout_width="match_parent" android:layout_height="46dp" android:text="登陆" android:id="@+id/register_button" android:textSize="16sp" android:layout_marginTop="20dp" android:background="@drawable/test" android:layout_marginLeft="35dp" android:layout_marginRight="35dp"/> </LinearLayout>
最后记得在这里声明一下
下面这里是设置启动页的,就是app启动时界面
-
基于AndroidStudio的欢迎界面跳转
2017-10-17 14:03:36基于AS编写的的欢迎界面,2秒后跳转,我自己照着网上的例子编写的,已经实现功能 -
android H5跳转到安卓app界面
2019-08-29 11:29:01开发时有时会碰到这样的需求,分享到第三方的h5页面,在点击操作的时候需要跳回APP的指定页面,这时只需要在该activity下面配置一下相应的scheme host等信息就可以了 <intent-filter> <action android:... -
Html5跳转到APP指定页面的实现
2020-11-21 17:21:36比如我的设为iOSTencentTest,在浏览器中输入地址iOSTencentTest://即可跳转到我的app 2.跳转到指定页面 在使用iOSTencentTest://打开app会调用AppDelegate的代理方法 -(BOOL)application:(UIApplication *)app ... -
Android 接收推送消息跳转到指定页面的方法
2021-01-21 20:19:15这时候要展示通知,点击通知栏打开App并跳转到目标页面,关闭目标页面后需要返回到应用首页,而不是直接推出App 实现思路 App在前台时,弹出Dialog提醒用户有新消息,但是最新版的个推文档接收推送消息是继承... -
Android url 跳转 app 指定界面
2021-07-20 11:43:02data android:scheme="scheme" android:host="host" android:path="/detail" /> 在需要跳转的地方加 val url = "scheme://host/detail" var intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) context... -
【Android 产品研发】-->App 跳转另一个 App 指定页面
2022-04-13 16:03:08一个 app 打开另一个 app 的指定页面方法有以下几种 通过包名、类名 通过 intent 的 action 通过 Url -
APP跳转支付宝指定界面
2021-06-06 09:49:50///跳转支付宝指定界面前面需要拼接 alipays://platformapi/startapp?appId=20000067&url=%@NSString *alipayUrl = [NSString stringWithFormat:@"alipays://platformapi/startapp?appId=20000067&am... -
Android跳转至抖音APP个人界面(包括极速版,火山版)
2022-03-24 00:11:05最近想给自己准备上架的APP增加一个个人广告,设置点击跳转到博主的抖音个人界面。包括抖音,抖音极速版,抖音火山版。 -
Android实现界面跳转功能
2021-01-21 19:37:06本文实例为大家分享了Android实现界面跳转的具体代码,供大家参考,具体内容如下 布局 <?xml version=1.0 encoding=utf-8?> <android.support.constraint.ConstraintLayout xmlns:android=... -
Flutter中如何进行界面跳转
2021-01-03 21:55:38在android开发中界面都是对应着一个个Activity,我们通过intent从一个界面启动另外一个。路由(Route)在移动开发中通常指页面(Page),所谓路由管理,就是管理页面之间如何跳转,通常也可被称为导航管理。导航管理... -
android:scheme 通过uri跳转到APP应用指定Activity
2016-05-11 10:29:54android:scheme 通过uri跳转到APP应用指定Activity -
h5跳转安卓原生app
2020-12-28 23:30:441.安卓app端代码 import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.webkit.JavascriptInterface; import android.webkit.... -
详解Android App卸载后跳转到指定的反馈页面的方法
2020-09-02 11:05:38主要介绍了Android App卸载后跳转到指定的反馈页面的方法,关键点是相关线程要判断在目录被消除以前作出响应,需要的朋友可以参考下 -
Android Scheme的跳转协议,跳转到app的指定页面
2021-06-05 05:14:33Scheme协议Android中的Scheme是一种页面内跳转协议,通过自定义Scheme协议,可以跳转到app中的任何页面服务器可以定制化跳转app页面app可以通过Scheme跳转到另一个app页面可以通过h5页面跳转app原生页面定义协议的... -
Andriod实现简单的微信界面跳转
2021-01-20 08:45:13Andriod实现简单的微信界面跳转 运行结果如下: import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.... -
Android Studio 利用Splash制作APP启动界面的方法
2021-01-03 11:43:11最近又开始学习Android studio 了,在制作APP时,都有一个启动的界面,看上去美观且实用(也可以作为以后的广告位← 那怎样制作呢? 第一步:新建Splash 如图,新建一个Empty Activity。 然后将名字改为... -
Android实现界面跳转
2020-03-30 18:08:532. 实现跳转 3. 其它方式 1. 主界面 新建一个AndroidStudio项目 建好过后默认是一个 hello world 项目,我们不使用它提供的文件,对于我们需要使用的代码,我们自己建立文件。 在 app/src/main/java/... -
Android如何跳转窗口,android界面跳转——进入新界面和界面回退
2021-06-03 06:17:52本实例是有三个activity和3个xml文件。...thirdactivity_main.xmlxmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:paddingBo... -
Android/IOS 实现接触NFC自动跳转到App,如果未安装App,则跳转到应用市场
2022-03-01 17:14:34某些共享电单车的友商最近推出了手机碰一碰NFC自动跳转到App自动开锁的功能,这个对于用户体验是有提升的,所以研究了一下。 友商的逻辑是这样的 如果已安装App,接触NFC自动跳转到App 如果未安装App,则跳转到应用... -
Android从当前APP跳转到其他应用
2021-06-07 03:52:491、从当前APP跳转到其它App的某个Activity在App中跳转到其它APP中指定的Activity,需要满足以下条件:1)目标APP的指定Activity允许其他应用访问2)知晓目标APP包名以及目标Activity的完整路径3)目标APP的目标Activity...