From 33857997da4e957f808693fd95868497e0699542 Mon Sep 17 00:00:00 2001
From: = <=>
Date: Fri, 17 May 2019 20:02:05 +0800
Subject: [PATCH 1/2] json
---
students/soft1714080902301/json/test.json | 24 +++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/students/soft1714080902301/json/test.json b/students/soft1714080902301/json/test.json
index 121b6dea6..da5dd7235 100644
--- a/students/soft1714080902301/json/test.json
+++ b/students/soft1714080902301/json/test.json
@@ -11,6 +11,30 @@
{
"spname": "商品2",
"spprice": "价格2"
+ },
+ {
+ "spname": "商品3",
+ "spprice": "价格3"
+ },
+ {
+ "spname": "商品4",
+ "spprice": "价格4"
+ },
+ {
+ "spname": "商品5",
+ "spprice": "价格5"
+ },
+ {
+ "spname": "商品6",
+ "spprice": "价格6"
+ },
+ {
+ "spname": "商品7",
+ "spprice": "价格7"
+ },
+ {
+ "spname": "商品8",
+ "spprice": "价格8"
}
]
}
\ No newline at end of file
From dbcbffa6be2f8164fb6e8c3080e2c560268b1b66 Mon Sep 17 00:00:00 2001
From: = <=>
Date: Fri, 17 May 2019 22:44:22 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E5=AE=9E=E9=AA=8C8=E5=A4=A7=E4=BD=9C?=
=?UTF-8?q?=E4=B8=9A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/main/AndroidManifest.xml" | 33 +++
.../example/myapplication/Main2Activity.java" | 199 +++++++++++++++
.../example/myapplication/Main3Activity.java" | 123 +++++++++
.../example/myapplication/Main4Activity.java" | 238 ++++++++++++++++++
.../example/myapplication/MainActivity.java" | 37 +++
.../src/main/res/anim/anim.xml" | 4 +
.../src/main/res/anim/in.xml" | 10 +
.../src/main/res/anim/out.xml" | 10 +
.../res/drawable/ic_launcher_background.xml" | 170 +++++++++++++
.../src/main/res/drawable/shape.xml" | 8 +
.../src/main/res/layout/activity_main.xml" | 229 +++++++++++++++++
.../src/main/res/layout/activity_main2.xml" | 96 +++++++
.../src/main/res/layout/activity_main3.xml" | 64 +++++
.../src/main/res/layout/activity_main4.xml" | 68 +++++
.../src/main/res/values/styles.xml" | 45 ++++
15 files changed, 1334 insertions(+)
create mode 100644 "students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/AndroidManifest.xml"
create mode 100644 "students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/java/com/example/myapplication/Main2Activity.java"
create mode 100644 "students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/java/com/example/myapplication/Main3Activity.java"
create mode 100644 "students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/java/com/example/myapplication/Main4Activity.java"
create mode 100644 "students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/java/com/example/myapplication/MainActivity.java"
create mode 100644 "students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/anim/anim.xml"
create mode 100644 "students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/anim/in.xml"
create mode 100644 "students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/anim/out.xml"
create mode 100644 "students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/drawable/ic_launcher_background.xml"
create mode 100644 "students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/drawable/shape.xml"
create mode 100644 "students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/layout/activity_main.xml"
create mode 100644 "students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/layout/activity_main2.xml"
create mode 100644 "students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/layout/activity_main3.xml"
create mode 100644 "students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/layout/activity_main4.xml"
create mode 100644 "students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/values/styles.xml"
diff --git "a/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/AndroidManifest.xml" "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/AndroidManifest.xml"
new file mode 100644
index 000000000..9f33f325e
--- /dev/null
+++ "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/AndroidManifest.xml"
@@ -0,0 +1,33 @@
+
+
+
+
+
+ android:maxSdkVersion="18" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git "a/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/java/com/example/myapplication/Main2Activity.java" "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/java/com/example/myapplication/Main2Activity.java"
new file mode 100644
index 000000000..bcfabcf2d
--- /dev/null
+++ "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/java/com/example/myapplication/Main2Activity.java"
@@ -0,0 +1,199 @@
+package com.example.myapplication;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.os.Environment;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+
+public class Main2Activity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main2);
+ Button button=(Button)findViewById(R.id.button);
+ button.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ TextView spsl=findViewById(R.id.spsl);
+ TextView sl=findViewById(R.id.sl);
+ TextView spjg=findViewById(R.id.spjg);
+ TextView jg=findViewById(R.id.jg);
+ TextView spdd=findViewById(R.id.spdd);
+ TextView ddh=findViewById(R.id.ddh);
+ String text=spsl.getText().toString()+sl.getText().toString()+"\n"+spjg.getText().toString()+jg.getText().toString()+"\n"+spdd.getText().toString()+ddh.getText().toString();
+ // Log.i("1",spsl.getText().toString());
+ //save(text);
+ saveTextIntoExternalStorage(text);
+
+ }
+ });
+ }
+ private void save(String text){
+ // 获取内部存储目录
+ File dir = this.getFilesDir();
+ //File dir = getCacheDir();
+ File file = new File(dir,"test.txt");
+ if (file.exists()) { // 判断文件是否存在
+ Log.i("TAG", file.getAbsolutePath());
+ Log.i("TAG", file.length() + ""); // bytes*1024=kb *1024 MB
+ Log.i("TAG", file.isFile() + "");
+ file.canRead();
+ file.canWrite();
+ file.canExecute();
+
+ file.getFreeSpace();
+ file.getTotalSpace();
+ }
+
+ FileOutputStream fos = null; // 字节流 | char | cn : gbk 2 bytes, utf8 3 bytes
+
+ try { // 使用API打开输出流
+ fos = openFileOutput("test.txt", MODE_PRIVATE);
+ //FileOutputStream fos = new FileOutputStream(file);
+ fos.write(text.getBytes()); // 写入内容
+ fos.close(); // 关闭流
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ fos.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ FileReader reader = null; // char
+
+ try {
+ reader = new FileReader(file.getAbsoluteFile());
+ String line;
+ BufferedReader bReader = new BufferedReader(reader);
+ while ((line =bReader.readLine())!=null){
+ Log.i("读取","从文件读取的内容: " + line);
+ }
+ bReader.close();
+ reader.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ // 显示结果
+ showResult(file.getAbsolutePath());
+
+ // 删除文件
+ file.delete();
+ deleteFile("test.txt");
+ }
+
+ // 将文字保存到外部存储
+ private void saveTextIntoExternalStorage(String text) {
+ if (!isExternalStorageWritable()) {
+ Log.e("外部存储", "外部存储不可写!");
+ return;
+ }
+
+ File dir = getPublicExtStorageDir("DIRECTORY", Environment.DIRECTORY_DOWNLOADS);
+ File file = new File(dir, "test01.txt");
+
+ try {
+ FileOutputStream fos = new FileOutputStream(file);
+ fos.write(text.getBytes());
+ fos.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ FileReader reader = null;
+ try {
+ reader = new FileReader(file.getAbsoluteFile());
+ String line;
+ BufferedReader bReader = new BufferedReader(reader);
+ while ((line =bReader.readLine())!=null){
+ Log.i("读取","从文件读取的内容: " + line);
+ }
+ bReader.close();
+ reader.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ // 显示结果
+ showResult(file.getAbsolutePath());
+ }
+
+ /* Checks if external storage is available for read and write */
+ private boolean isExternalStorageWritable() {
+ String state = Environment.getExternalStorageState();
+ if (Environment.MEDIA_MOUNTED.equals(state)) {
+ return true;
+ }
+ return false;
+ }
+
+ /* Checks if external storage is available to at least read */
+ private boolean isExternalStorageReadable() {
+ String state = Environment.getExternalStorageState();
+ if (Environment.MEDIA_MOUNTED.equals(state) ||
+ Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
+ return true;
+ }
+ return false;
+ }
+
+ // 创建公开的外部存储目录(App卸载时不会删除)
+ private File getPublicExtStorageDir(String dirName, String type) {
+ if (type == null) { // 指定文件类型
+ type = Environment.DIRECTORY_PICTURES;
+ }
+ File dir = new File(Environment.getExternalStoragePublicDirectory(type), dirName);
+ if (!dir.mkdirs()) {
+ Log.e("无法创建", "目录无法创建!");
+ }
+
+ long freeSpace = dir.getFreeSpace();
+ Log.i("剩余空间", "剩余空间大小: " + (freeSpace / 1024 / 1024) + "MB");
+ long totalSpace = dir.getTotalSpace();
+ Log.i("总空间", "总空间大小: " + (totalSpace / 1024 / 1024) + "MB");
+
+ return dir;
+ }
+
+ // 创建私有的外部存储目录(App卸载时会一同删除)
+ private File getPrivateExtStorageDir(Context context, String dirName, String type) {
+ if (type == null) { // 指定文件类型
+ type = Environment.DIRECTORY_PICTURES;
+ }
+ File file = new File(context //
+ .getExternalFilesDir(type), dirName);
+ if (!file.mkdirs()) {
+ Log.e("无法创建", "目录无法创建!");
+ }
+ return file;
+ }
+
+
+ private void showResult(String result) {
+ ((TextView) findViewById(R.id.text_path)) //
+ .setText(result.toCharArray(), 0, result.length());
+ }
+}
diff --git "a/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/java/com/example/myapplication/Main3Activity.java" "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/java/com/example/myapplication/Main3Activity.java"
new file mode 100644
index 000000000..b8194f8d0
--- /dev/null
+++ "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/java/com/example/myapplication/Main3Activity.java"
@@ -0,0 +1,123 @@
+package com.example.myapplication;
+
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import android.view.View;
+import android.widget.ImageButton;
+import android.widget.TextView;
+
+import org.json.JSONObject;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+public class Main3Activity extends AppCompatActivity {
+ String mCurrentPhotoPath;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main3);
+ getJson();
+ ImageButton imageButton=(ImageButton)findViewById(R.id.imageButton);
+ imageButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ //dispatchTakePictureIntent();
+
+ Intent intent=new Intent(Main3Activity.this,Main4Activity.class);
+ startActivityForResult(intent,123);
+
+ }
+ });
+ }
+ public void getJson(){
+ Thread thread=new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ String url_s="https://raw.githubusercontent.com/517865058/android-labs-2019/master/students/soft1714080902301/json/test.json";
+
+ URL url=new URL(url_s);
+ HttpURLConnection conn = (HttpURLConnection)url.openConnection();
+ conn.setConnectTimeout(5000);//设置超时
+ conn.setUseCaches(false);//数据不多不用缓存了
+ conn.connect();
+ InputStream inputStream=conn.getInputStream();
+ InputStreamReader inputStreamReader=new InputStreamReader(inputStream);
+ BufferedReader bufferedReader=new BufferedReader(inputStreamReader);
+
+ if (conn.getResponseCode()==200){
+ String inputLine;
+ StringBuffer resultData=new StringBuffer();
+ while ((inputLine=bufferedReader.readLine())!=null){
+ resultData.append(inputLine);
+ }
+ String text=resultData.toString();
+ Log.v("out-----",text);
+ JSONObject jsonObject=new JSONObject(text);
+ TextView textView=(TextView)findViewById(R.id.name);
+ TextView textView1=(TextView)findViewById(R.id.username);
+ textView.setText(jsonObject.getString("name"));
+ textView1.setText(jsonObject.getString("username"));
+ //JSONArray jsonArray=jsonObject.getJSONArray("");
+
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+
+ }
+ });
+ thread.start();
+ }
+ @Override
+ protected void onActivityResult(int requestCode,int resultCode,Intent data){
+ if(resultCode==RESULT_OK){
+ String result = data.getExtras().getString("data");
+ mCurrentPhotoPath=result;
+ Log.e("data",mCurrentPhotoPath);
+ if(mCurrentPhotoPath!=null){
+ setPic();
+ //Bitmap bitmap = BitmapFactory.decodeFile(mCurrentPhotoPath);
+ //ImageButton imageButton=findViewById(R.id.imageButton);
+ //imageButton.setImageBitmap(bitmap);
+ }}
+
+
+ }
+ private void setPic() {
+ ImageButton imageButton=findViewById(R.id.imageButton);
+ int targetW = imageButton.getWidth();
+ int targetH = imageButton.getHeight();
+ BitmapFactory.Options bmOptions = new BitmapFactory.Options();
+ bmOptions.inJustDecodeBounds = true;
+ BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);
+ int photoW = bmOptions.outWidth;
+ int photoH = bmOptions.outHeight;
+ // Determine how much to scale down the image
+ int scaleFactor = Math.min(photoW/targetW, photoH/targetH);
+ // Decode the image file into a Bitmap sized to fill the View
+ bmOptions.inJustDecodeBounds = false;
+ bmOptions.inSampleSize = scaleFactor;
+ File file=new File(mCurrentPhotoPath);
+ Uri uri=Uri.fromFile(file);
+ Bitmap bitmap = BitmapFactory.decodeFile(uri.getPath(), bmOptions);
+ imageButton.setImageBitmap(bitmap);
+ }
+
+
+
+ }
+
+
+
diff --git "a/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/java/com/example/myapplication/Main4Activity.java" "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/java/com/example/myapplication/Main4Activity.java"
new file mode 100644
index 000000000..9e485aef5
--- /dev/null
+++ "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/java/com/example/myapplication/Main4Activity.java"
@@ -0,0 +1,238 @@
+package com.example.myapplication;
+
+import android.Manifest;
+import android.content.ContentResolver;
+import android.content.ContentUris;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.database.Cursor;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Environment;
+import android.os.StrictMode;
+import android.provider.DocumentsContract;
+import android.provider.MediaStore;
+import android.support.annotation.NonNull;
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.content.ContextCompat;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import android.view.MotionEvent;
+import android.view.View;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.Toast;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class Main4Activity extends AppCompatActivity {
+ String mCurrentPhotoPath;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main4);
+ StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
+ StrictMode.setVmPolicy(builder.build());
+ builder.detectFileUriExposure();
+
+ Button take = (Button) this.findViewById(R.id.take);
+ Button pick = (Button) this.findViewById(R.id.pick);
+ Button cancle = (Button) this.findViewById(R.id.cancle);
+
+ LinearLayout layout=(LinearLayout)findViewById(R.id.layout);
+
+ //添加选择窗口范围监听可以优先获取触点,即不再执行onTouchEvent()函数,点击其他地方时执行onTouchEvent()函数销毁Activity
+ layout.setOnClickListener(new View.OnClickListener() {
+
+ public void onClick(View v) {
+ // TODO Auto-generated method stub
+ Toast.makeText(getApplicationContext(), "提示:点击窗口外部关闭窗口!",
+ Toast.LENGTH_SHORT).show();
+ }
+ });
+ //添加按钮监听
+ cancle.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Main4Activity.this.setResult(0);
+ finish();
+ }
+ });
+ pick.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ selectPic();
+ }
+ });
+ take.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ getQx();
+
+ }
+ });
+ }
+
+ //实现onTouchEvent触屏函数但点击屏幕时销毁本Activity
+ @Override
+ public boolean onTouchEvent(MotionEvent event){
+ finish();
+ return true;
+ }
+
+
+ private File createImageFile() throws IOException {
+ // Create an image file name
+ String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
+ String imageFileName = "JPEG_" + timeStamp + "_";
+ File storageDir = Environment.getExternalStoragePublicDirectory(
+ Environment.DIRECTORY_PICTURES);
+ File image = File.createTempFile(
+ imageFileName, /* prefix */
+ ".jpg", /* suffix */
+ storageDir /* directory */
+ );
+ // Save a file: path for use with ACTION_VIEW intents
+ mCurrentPhotoPath = image.getAbsolutePath();
+ return image;
+ }
+ static final int REQUEST_TAKE_PHOTO = 1;
+ private void dispatchTakePictureIntent() {
+ Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
+ // Ensure that there's a camera activity to handle the intent
+ if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
+ // Create the File where the photo should go
+ File photoFile = null;
+ try {
+ photoFile = createImageFile();
+ } catch (IOException ex) {
+ // Error occurred while creating the File
+ ex.printStackTrace();
+ Log.e("error:","creat error!");
+ }
+ // Continue only if the File was successfully created
+ if (photoFile != null) {
+ takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
+ Uri.fromFile(photoFile));
+ startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
+ }
+ }
+ }
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data){
+ if (requestCode == REQUEST_TAKE_PHOTO&& resultCode == RESULT_OK){
+ if(galleryAddPic()==true){
+ Intent intent=new Intent();
+ intent.putExtra("data",mCurrentPhotoPath);
+ Main4Activity.this.setResult(RESULT_OK,intent);
+ Main4Activity.this.finish();
+ }
+
+ }
+ else if (requestCode==123&&resultCode == RESULT_OK){
+ //获取选中文件的定位符
+ Uri uri = data.getData();
+ String imagePath=null;
+ if (DocumentsContract.isDocumentUri(this,uri)){
+ //如果是document类型的uri 则通过id进行解析处理
+ String docId = DocumentsContract.getDocumentId(uri);
+ if ("com.android.providers.media.documents".equals(uri.getAuthority())){
+ //解析出数字格式id
+ String id = docId.split(":")[1];
+ String selection = MediaStore.Images.Media._ID + "=" +id;
+ imagePath = getImagePath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,selection);
+ }else if ("com.android.providers.downloads.documents".equals(uri.getAuthority())){
+ Uri contentUri = ContentUris.withAppendedId(Uri.parse("" +
+ "content://downloads/public_downloads"),Long.valueOf(docId));
+ imagePath = getImagePath(contentUri,null);
+ }
+ }else if ("content".equals(uri.getScheme())){
+ //如果不是document类型的uri,则使用普通的方式处理
+ imagePath = getImagePath(uri,null);
+ }
+ mCurrentPhotoPath=imagePath;
+ Intent intent=new Intent();
+ intent.putExtra("data",mCurrentPhotoPath);
+ Main4Activity.this.setResult(RESULT_OK,intent);
+ Main4Activity.this.finish();
+ }
+
+ }
+
+ private String getImagePath(Uri uri, String seletion){
+ String path = null;
+ Cursor cursor = getContentResolver().query(uri,null,seletion,null,null);
+ if (cursor != null){
+ if (cursor.moveToFirst()) {
+ path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));
+ }
+ cursor.close();
+ }
+ return path;
+ }
+ private boolean galleryAddPic() {
+ if (mCurrentPhotoPath!=null){
+ Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
+ File f = new File(mCurrentPhotoPath);
+ Uri contentUri = Uri.fromFile(f);
+ mediaScanIntent.setData(contentUri);
+ this.sendBroadcast(mediaScanIntent);
+ return true;}
+ else return false;
+ }
+ public void getQx(){
+ int checkResult = ContextCompat.checkSelfPermission(Main4Activity.this, Manifest.permission.CALL_PHONE);
+ boolean hasPermission=checkResult== PackageManager.PERMISSION_GRANTED;
+ if(!hasPermission&&ContextCompat.checkSelfPermission(Main4Activity.this,
+ Manifest.permission.WRITE_EXTERNAL_STORAGE)!=PackageManager.PERMISSION_GRANTED){
+ ActivityCompat.requestPermissions(Main4Activity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 111);
+ }
+ else dispatchTakePictureIntent();
+ }
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+ if (grantResults[0] != PackageManager.PERMISSION_GRANTED) {
+ Toast.makeText(this, "权限授予失败", Toast.LENGTH_SHORT).show();
+ } else {
+ Toast.makeText(this, "权限授予成功", Toast.LENGTH_SHORT).show();
+ dispatchTakePictureIntent();
+ //todo 搞事情
+ }
+ }
+ private void selectPic(){
+ //intent可以应用于广播和发起意图,其中属性有:ComponentName,action,data等
+ Intent intent=new Intent();
+ intent.setType("image/*");
+ //action表示intent的类型,可以是查看、删除、发布或其他情况;我们选择ACTION_GET_CONTENT,系统可以根据Type类型来调用系统程序选择Type
+ //类型的内容给你选择
+ intent.setAction(Intent.ACTION_GET_CONTENT);
+ //如果第二个参数大于或等于0,那么当用户操作完成后会返回到本程序的onActivityResult方法
+ startActivityForResult(intent, 123);
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+
+
+
+
diff --git "a/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/java/com/example/myapplication/MainActivity.java" "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/java/com/example/myapplication/MainActivity.java"
new file mode 100644
index 000000000..da16f8063
--- /dev/null
+++ "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/java/com/example/myapplication/MainActivity.java"
@@ -0,0 +1,37 @@
+package com.example.myapplication;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.view.View;
+import android.widget.Button;
+
+public class MainActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ Button button=(Button) findViewById(R.id.v);
+ button.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+
+ // 另一个Activity的完整名称 = edu.androidlabs.soft123456(包名小写).Soft123456Activity(类名)
+ Intent intent = new Intent(MainActivity.this,Main2Activity.class);
+ startActivity(intent);
+ //startActivity(intent);
+
+ }
+ });
+ Button button1=(Button) findViewById(R.id.me);
+ button1.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(MainActivity.this,Main3Activity.class);
+ startActivity(intent);
+ }
+ });
+
+ }
+}
diff --git "a/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/anim/anim.xml" "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/anim/anim.xml"
new file mode 100644
index 000000000..751d2da5e
--- /dev/null
+++ "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/anim/anim.xml"
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git "a/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/anim/in.xml" "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/anim/in.xml"
new file mode 100644
index 000000000..77bd77213
--- /dev/null
+++ "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/anim/in.xml"
@@ -0,0 +1,10 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git "a/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/anim/out.xml" "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/anim/out.xml"
new file mode 100644
index 000000000..5075fc062
--- /dev/null
+++ "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/anim/out.xml"
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git "a/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/drawable/ic_launcher_background.xml" "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/drawable/ic_launcher_background.xml"
new file mode 100644
index 000000000..0d025f9bf
--- /dev/null
+++ "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/drawable/ic_launcher_background.xml"
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git "a/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/drawable/shape.xml" "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/drawable/shape.xml"
new file mode 100644
index 000000000..b7f4f70d2
--- /dev/null
+++ "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/drawable/shape.xml"
@@ -0,0 +1,8 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git "a/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/layout/activity_main.xml" "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/layout/activity_main.xml"
new file mode 100644
index 000000000..18ac38049
--- /dev/null
+++ "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/layout/activity_main.xml"
@@ -0,0 +1,229 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git "a/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/layout/activity_main2.xml" "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/layout/activity_main2.xml"
new file mode 100644
index 000000000..16cdee64d
--- /dev/null
+++ "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/layout/activity_main2.xml"
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git "a/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/layout/activity_main3.xml" "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/layout/activity_main3.xml"
new file mode 100644
index 000000000..b3f875e5d
--- /dev/null
+++ "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/layout/activity_main3.xml"
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git "a/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/layout/activity_main4.xml" "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/layout/activity_main4.xml"
new file mode 100644
index 000000000..5e90b04a8
--- /dev/null
+++ "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/layout/activity_main4.xml"
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git "a/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/values/styles.xml" "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/values/styles.xml"
new file mode 100644
index 000000000..9f42eac19
--- /dev/null
+++ "b/students/soft1714080902301/\345\256\236\351\252\2148\345\244\247\344\275\234\344\270\232/src/main/res/values/styles.xml"
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+