Skip to content

Commit

Permalink
添加说明
Browse files Browse the repository at this point in the history
  • Loading branch information
huangyuanlove committed Apr 17, 2019
1 parent 45b0c2e commit 59cfd0e
Show file tree
Hide file tree
Showing 8 changed files with 410 additions and 20 deletions.
374 changes: 371 additions & 3 deletions README.MD

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.huangyuanlove.adaptationhighversion;

import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

Expand All @@ -25,6 +26,38 @@ protected void onCreate(Bundle savedInstanceState) {
findViewById(R.id.public_file).setOnClickListener(this);
findViewById(R.id.public_index_file).setOnClickListener(this);
findViewById(R.id.external_private_file).setOnClickListener(this);

Log.e("filePath",getFilesDir().getPath());
Log.e("filePath",getCacheDir().getPath());
Log.e("filePath",getExternalCacheDir().getPath());
Log.e("filePath",getExternalFilesDir(null).getPath());
Log.e("filePath",Environment.getExternalStorageDirectory().getPath());
Log.e("filePath",Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath());


try{
File privateCachedFile = new File(getCacheDir().getPath() +"/privateCachedFile.txt");
if(!privateCachedFile.exists()){
privateCachedFile.createNewFile();
}

Log.e("privateCachedFile",privateCachedFile.getPath());


File externalCacheFile = new File( getExternalCacheDir().getPath() +"/externalCacheFile.txt" );
if(!externalCacheFile.exists()){
externalCacheFile.createNewFile();
}

Log.e("externalCacheFile",externalCacheFile.getPath());

}catch (Exception e){
e.printStackTrace();
}




}

@Override
Expand Down Expand Up @@ -55,7 +88,7 @@ public void onClick(View v) {
try {
//需要申请权限
String externalStorageFilePath = Environment.getExternalStorageDirectory().getPath();
File externalFile = new File(externalStorageFilePath + "/publicFile.txt");
File externalFile = new File(externalStorageFilePath + "/externalFile.txt");
if (!externalFile.exists()) {
externalFile.createNewFile();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import android.support.annotation.RequiresApi;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

Expand Down Expand Up @@ -104,7 +103,6 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
//用户只点击了禁止,没有选择不再提示
Toast.makeText(MainActivity.this, "用户禁止了" + permission + "权限", Toast.LENGTH_SHORT).show();


} else {

//解释原因,并且引导用户至设置页手动授权
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
import android.app.NotificationManager;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.DocumentsContract;
import android.provider.OpenableColumns;
import android.support.v4.provider.DocumentFile;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

public class SAFActivity extends AppCompatActivity implements View.OnClickListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
import android.content.pm.ShortcutManager;
import android.graphics.drawable.Icon;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

Expand Down Expand Up @@ -63,7 +61,6 @@ private void removeShortcut() {
//动态添加并且在桌面创建了快捷方式,删除之前,先disable一下. 或者判断
List<ShortcutInfo> shortcutInfos = shortcutManager.getPinnedShortcuts();


for(ShortcutInfo si : shortcutInfos){
if(si.getId().equals("shortcut")){
shortcutManager.disableShortcuts(Arrays.asList(new String[]{"shortcut"}));
Expand All @@ -73,7 +70,6 @@ private void removeShortcut() {

Toast.makeText(ShortCutActivity.this,"共" + shortcutInfos.size() +"个桌面快捷方式",Toast.LENGTH_SHORT).show();


}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

Expand Down Expand Up @@ -41,7 +41,6 @@ public void onClick(View v) {
switch (v.getId()) {
case R.id.take_photo:
try {

//指定Uri,拍照返回的data为空
String tempImagePath = getFilesDir().getPath();
tempImageFile = File.createTempFile("image_", ".jpg", new File(tempImagePath));
Expand Down
Binary file added image/uninstall_apk_dialog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 59cfd0e

Please sign in to comment.