Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
c03ed23b
Commit
c03ed23b
authored
Jan 08, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化GP跳转逻辑
parent
abaae597
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
14 deletions
+41
-14
src/main/java/tech/starwin/utils/context_utils/ActivityJumper.java
+38
-14
src/main/java/tech/starwin/utils/context_utils/AppInfoUtils.java
+3
-0
No files found.
src/main/java/tech/starwin/utils/context_utils/ActivityJumper.java
View file @
c03ed23b
...
...
@@ -20,6 +20,7 @@ import com.tbruyelle.rxpermissions2.Permission;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.Map
;
import
tech.starwin.LibConfig
;
import
tech.starwin.R
;
...
...
@@ -34,6 +35,7 @@ import tech.starwin.utils.ui_utils.DialogManager;
*/
public
class
ActivityJumper
{
private
static
String
GP_APP_DETAIL_URL
=
"https://play.google.com/store/apps/details?id="
;
private
static
String
GP_PACKAGE_NAME
=
"com.android.vending"
;
private
Intent
intent
;
private
static
int
REQUEST_PERMISSION_CODE
=
0x000AF00
;
/**
...
...
@@ -164,23 +166,45 @@ public class ActivityJumper {
}
// public static void startGooglePlay(Context context, String packageName) {
// try {
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(GP_APP_DETAIL_URL + packageName));
// List<ResolveInfo> resolveInfos = context.getPackageManager().queryIntentActivities(intent, 0);
// if (resolveInfos != null && resolveInfos.size() > 0) {
// for (ResolveInfo resolveInfo : resolveInfos) {
// if (resolveInfo.activityInfo.packageName.toLowerCase().contains("com.android.vending")
// || resolveInfo.activityInfo.name.toLowerCase().contains("com.android.vending")
// || resolveInfo.activityInfo.processName.toLowerCase().contains("com.android.vending")) {
// intent.setPackage(resolveInfo.activityInfo.packageName);
// break;
// }
// }
// }
// context.startActivity(intent);
// } catch (Exception e) {
// DialogFactory.showMessageDialog(context, context.getString(R.string.show_download_on_google_player));
// }
// }
/**
* 打开Google Play下载页
*/
public
static
void
startGooglePlay
(
Context
context
,
String
packageName
)
{
try
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
GP_APP_DETAIL_URL
+
packageName
));
List
<
ResolveInfo
>
resolveInfos
=
context
.
getPackageManager
().
queryIntentActivities
(
intent
,
0
);
if
(
resolveInfos
!=
null
&&
resolveInfos
.
size
()
>
0
)
{
for
(
ResolveInfo
resolveInfo
:
resolveInfos
)
{
if
(
resolveInfo
.
activityInfo
.
packageName
.
toLowerCase
().
contains
(
"com.android.vending"
)
||
resolveInfo
.
activityInfo
.
name
.
toLowerCase
().
contains
(
"com.android.vending"
)
||
resolveInfo
.
activityInfo
.
processName
.
toLowerCase
().
contains
(
"com.android.vending"
))
{
intent
.
setPackage
(
resolveInfo
.
activityInfo
.
packageName
);
break
;
}
}
//已安装GooglePlay直接打开,否则用浏览器访问App下载页
Uri
uri
=
Uri
.
parse
(
GP_APP_DETAIL_URL
+
packageName
);
if
(
AppInfoUtils
.
isPackageExist
(
context
,
GP_PACKAGE_NAME
))
{
Intent
intent
=
new
Intent
();
intent
.
setAction
(
Intent
.
ACTION_VIEW
)
.
setData
(
uri
)
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
if
(
AppInfoUtils
.
isPackageExist
(
context
,
GP_PACKAGE_NAME
))
{
intent
.
setPackage
(
GP_PACKAGE_NAME
);
}
context
.
startActivity
(
intent
);
}
catch
(
Exception
e
)
{
DialogFactory
.
showMessageDialog
(
context
,
context
.
getString
(
R
.
string
.
show_download_on_google_player
));
}
else
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
,
uri
);
context
.
startActivity
(
intent
);
}
}
...
...
src/main/java/tech/starwin/utils/context_utils/AppInfoUtils.java
View file @
c03ed23b
...
...
@@ -56,6 +56,7 @@ public class AppInfoUtils {
return
false
;
}
@SuppressLint
(
"MissingPermission"
)
public
static
String
getPhoneNumber
(
Context
context
)
{
TelephonyManager
telephonyManager
=
(
TelephonyManager
)
context
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
);
...
...
@@ -67,4 +68,6 @@ public class AppInfoUtils {
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment