Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
I
ios-ipad学生端
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
庄总
ios-ipad学生端
Commits
ba14a91c
Commit
ba14a91c
authored
Jan 12, 2022
by
fuyunfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加权限获取
parent
e5cdb86a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
android/app/src/main/java/com/fenghua_student_client/MainActivity.java
...rc/main/java/com/fenghua_student_client/MainActivity.java
+35
-0
No files found.
android/app/src/main/java/com/fenghua_student_client/MainActivity.java
View file @
ba14a91c
package
com.fenghua_student_client
;
package
com.fenghua_student_client
;
import
android.app.Activity
;
import
android.content.pm.PackageManager
;
import
android.os.Bundle
;
import
androidx.core.app.ActivityCompat
;
import
com.facebook.react.ReactActivity
;
import
com.facebook.react.ReactActivity
;
public
class
MainActivity
extends
ReactActivity
{
public
class
MainActivity
extends
ReactActivity
{
//先定义
private
static
final
int
REQUEST_EXTERNAL_STORAGE
=
1
;
private
static
String
[]
PERMISSIONS_STORAGE
=
{
"android.permission.READ_EXTERNAL_STORAGE"
,
"android.permission.WRITE_EXTERNAL_STORAGE"
};
//然后通过一个函数来申请
private
void
verifyStoragePermissions
(
Activity
activity
)
{
try
{
//检测是否有写的权限
int
permission
=
ActivityCompat
.
checkSelfPermission
(
activity
,
"android.permission.WRITE_EXTERNAL_STORAGE"
);
if
(
permission
!=
PackageManager
.
PERMISSION_GRANTED
)
{
// 没有写的权限,去申请写的权限,会弹出对话框
ActivityCompat
.
requestPermissions
(
activity
,
PERMISSIONS_STORAGE
,
REQUEST_EXTERNAL_STORAGE
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
// 申请权限
verifyStoragePermissions
(
this
);
}
/**
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
* rendering of the component.
...
...
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