我下载了一个源代码,我看到了一些错误,我无法修复我的下面列出的
MainActivity.java
package com.droidoxy.pocket;
导入android.transition时也出错。*;
private void checkReadPhoneStatePermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!hasGetReadPhoneStatePermission()) {
requestReadPhoneStatePermission();
}
}
}
private boolean hasGetReadPhoneStatePermission() {
return ContextCompat.checkSelfPermission(this, android.Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED;
}
private void requestReadPhoneStatePermission() {
//You can choose a more friendly notice text. And you can choose any view you like, such as dialog.
Toast.makeText(this, "Only grant the permission, can you start the mission!", Toast.LENGTH_SHORT).show();
ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.READ_PHONE_STATE}, REQUEST_READ_PHONE_STATE);
}
//Callback for requestPermission
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
try {
switch (requestCode) {
case REQUEST_READ_PHONE_STATE: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this, "The Permission has granted,you can get your mission now", Toast.LENGTH_SHORT).show();
} else {
//had not get the permission
Toast.makeText(this, "Not get the permission,so you cannot get your mission", Toast.LENGTH_SHORT).show();
}
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
值/ styles.xml
@色/ colorPrimary @颜色/ colorPrimaryDark
</style>
<item name="windowNoTitle">true</item>
</style>
答案 0 :(得分:0)
根据我的知识和Android version check
来判断**我改变了**
private void checkReadPhoneStatePermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!hasGetReadPhoneStatePermission()) {
requestReadPhoneStatePermission();
}
}
}
到
private void checkReadPhoneStatePermission() {
if (Build.VERSION.SDK_INT >= 23) {
if (!hasGetReadPhoneStatePermission()) {
requestReadPhoneStatePermission();
}
}
}
因为 M代表23 而 N代表24
其他人位于Get Android API level of phone currently running my application
<强>值/ styles.xml 强>
@ color / colorPrimary @ color / colorPrimaryDark
<item name="windowNoTitle">true</item>
我将 android:添加到它看起来像
<强>值/ styles.xml 强>
@ color / colorPrimary @ color / colorPrimaryDark
<item name="android:windowNoTitle">true</item>
不太了解但希望我需要帮助