我正试图通过锁定屏幕显示Google位置服务(打开GPS,网络数据等)对话框.
我正在使用KeyguardManager来禁用锁定屏幕.这可以正常工作,因为我的MainActivity能够禁用锁定屏幕.但是,只要Google位置服务对话框显示,锁定屏幕就会恢复启用,屏幕会被锁定,除非我解锁屏幕,否则无法进入我的MainActivity.
我甚至试过...... Flag_Show_When_Locked,但它没有帮助.
这是我的代码:
private KeyguardLock DisableScreenLock;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
setContentView(R.main_layout);
KeyguardManager myKeyGuard = (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);
DisableScreenLock = myKeyGuard.newKeyguardLock("disableKeyguard");
DisableScreenLock.disableKeyguard();
}
protected synchronized void GoogleApiClient_Intialize() {
Log.e(TAG, "Building GoogleApiClient");
googleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
}
protected void LocationRequest_Intialize() {
locationRequest = new LocationRequest();
locationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS);
locationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS);
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}
protected void LocationSettingsRequest_Builder() {
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
builder.addLocationRequest(locationRequest);
locationSettingsRequest = builder.build();
}
@Override
public void onConnected(Bundle connectionHint) {
Log.e(TAG, "GoogleApiClient is connected"); …Run Code Online (Sandbox Code Playgroud) android lockscreen android-networking location-services android-gps
旋转位图我遇到了很多麻烦.下面的代码有效,但它比Galaxy Note 2手机附带的Gallery应用程序慢4-6倍.
码:
File DirectoryFile = new File(Image_Path);
Bitmap bitmap = BitmapFactory.decodeFile(DirectoryFile.getAbsolutePath());
String imagePATH = FileLocation + "test.jpg";
final File newfile = new File(imagePATH);
FileOutputStream mFileOutputStream = null;
try {
mFileOutputStream = new FileOutputStream(newfile);
} catch (FileNotFoundException e1) { }
try {
Bitmap RotatedBitmap = RotateImage(imagePATH, bitmap);
RotatedBitmap.compress(Bitmap.CompressFormat.JPEG, 100, mFileOutputStream);
bitmap.recycle();
RotatedBitmap.recycle();
mFileOutputStream.flush();
mFileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
private Bitmap RotateImage(String filePath, Bitmap bitmap) throws IOException {
ExifInterface exif = new ExifInterface(filePath);
int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, …Run Code Online (Sandbox Code Playgroud) 我一直在努力研究如何在 Lollipop 上重命名 DocumentFile。很抱歉,我曾试图到处搜索解决方案,但似乎缺少有关此新 SD 卡访问 API 的在线信息。
这是我所拥有的:
String EditText = (Alert_EditText.getText().toString()).trim();
Uri uri = ListViewObject_List.get(LastItemPos).getImageUri();
final DocumentFile documentFile = DocumentFile.fromSingleUri(MainClass.this, uri);
documentFile.renameTo(EditText);
Run Code Online (Sandbox Code Playgroud)
它提出了一个 UnsupportedOperationException:
FATAL EXCEPTION: main
Process: com.camera.test, PID: 3362
java.lang.UnsupportedOperationException
at android.support.v4.provider.SingleDocumentFile.renameTo(SingleDocumentFile.java:105)
at com.camera.test.MainClass$21.onClick(MainClass.java:986)
at android.view.View.performClick(View.java:5242)
at android.widget.TextView.performClick(TextView.java:10530)
at android.view.View$PerformClick.run(View.java:21185)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6872)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Run Code Online (Sandbox Code Playgroud)
我也试过这个:
String EditText = (Alert_EditText.getText().toString()).trim();
Uri uri = ListViewObject_List.get(LastItemPos).getImageUri();
File file = new File(uri.getPath());
final DocumentFile documentFile = DocumentFile.fromFile(file); …Run Code Online (Sandbox Code Playgroud)