Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
request_install_packages
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李增强
request_install_packages
Commits
7bd62e93
Commit
7bd62e93
authored
Mar 27, 2021
by
李增强
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
m
parent
3cc749ff
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
5 deletions
+41
-5
android/src/main/AndroidManifest.xml
android/src/main/AndroidManifest.xml
+9
-1
android/src/main/java/com/qiaomeng/flutter/request_install_packages/Handler.java
...om/qiaomeng/flutter/request_install_packages/Handler.java
+23
-4
android/src/main/java/com/qiaomeng/flutter/request_install_packages/RequestInstallPackagesPlugin.java
...equest_install_packages/RequestInstallPackagesPlugin.java
+2
-0
lib/request_install_packages.dart
lib/request_install_packages.dart
+7
-0
No files found.
android/src/main/AndroidManifest.xml
View file @
7bd62e93
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.qiaomeng.flutter.request_install_packages"
>
xmlns:tools=
"http://schemas.android.com/tools"
package=
"com.qiaomeng.flutter.request_install_packages"
>
<uses-permission
android:name=
"android.permission.REQUEST_INSTALL_PACKAGES"
/>
<uses-permission
android:name=
"android.permission.INSTALL_SHORTCUT"
/>
<uses-permission
android:name=
"android.permission.INSTALL_PACKAGES"
tools:ignore=
"ProtectedPermissions"
/>
<uses-permission
android:name=
"android.permission.INSTALL_LOCATION_PROVIDER"
tools:ignore=
"ProtectedPermissions"
/>
<uses-permission
android:name=
"android.permission.INSTALL_PACKAGES"
tools:ignore=
"ProtectedPermissions"
/>
</manifest>
android/src/main/java/com/qiaomeng/flutter/request_install_packages/Handler.java
View file @
7bd62e93
...
...
@@ -103,10 +103,29 @@ public class Handler {
}
};
Uri
packageURI
=
Uri
.
parse
(
"package:"
+
mActivity
.
getPackageName
());
Intent
intent
=
new
Intent
(
Settings
.
ACTION_MANAGE_UNKNOWN_APP_SOURCES
,
packageURI
);
//系统将打开是未知来源应用的管理列表,需要用户手动设置未知来源应用安装权限
mActivity
.
startActivityForResult
(
intent
,
REQUESE_CODE
);
// ActivityCompat.requestPermissions(mActivity,new String[]{Manifest.permission.REQUEST_INSTALL_PACKAGES},REQUESE_CODE);
Thread
thread
=
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
Uri
packageURI
=
Uri
.
parse
(
"package:"
+
mActivity
.
getPackageName
());
Intent
intent
=
new
Intent
(
Settings
.
ACTION_MANAGE_UNKNOWN_APP_SOURCES
,
packageURI
);
//系统将打开是未知来源应用的管理列表,需要用户手动设置未知来源应用安装权限
mActivity
.
startActivityForResult
(
intent
,
REQUESE_CODE
);
}
});
thread
.
start
();
}
public
void
installApk
(
String
path
){
Intent
var5
=
new
Intent
(
"android.intent.action.VIEW"
);
var5
.
setDataAndType
(
Uri
.
parse
(
path
),
"apk"
);
try
{
mActivity
.
startActivity
(
var5
);
}
catch
(
Exception
var8
)
{
}
}
...
...
android/src/main/java/com/qiaomeng/flutter/request_install_packages/RequestInstallPackagesPlugin.java
View file @
7bd62e93
...
...
@@ -52,6 +52,8 @@ public class RequestInstallPackagesPlugin implements FlutterPlugin, MethodCallHa
handler
.
request
(
result
);
}
else
if
(
call
.
method
.
equals
(
"check"
))
{
handler
.
check
(
result
);
}
else
if
(
call
.
method
.
equals
(
"installApk"
))
{
handler
.
installApk
((
String
)
call
.
argument
(
"path"
));
}
else
{
result
.
notImplemented
();
}
...
...
lib/request_install_packages.dart
View file @
7bd62e93
...
...
@@ -20,4 +20,11 @@ class RequestInstallPackages {
}
return
_channel
.
invokeMethod
(
'check'
);
}
static
Future
<
bool
>
installApk
(
String
path
)
{
if
(!
Platform
.
isAndroid
)
{
return
Future
.
value
(
true
);
}
return
_channel
.
invokeMethod
(
'installApk'
,
{
"path"
:
path
});
}
}
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