Compare commits

..

4 Commits

@ -7,11 +7,11 @@
<deviceKey> <deviceKey>
<Key> <Key>
<type value="VIRTUAL_DEVICE_PATH" /> <type value="VIRTUAL_DEVICE_PATH" />
<value value="C:\Users\ZHY\.android\avd\Nexus_5X_API_30.avd" /> <value value="C:\Users\86188\.android\avd\Pixel_3a_API_33_x86_64.avd" />
</Key> </Key>
</deviceKey> </deviceKey>
</Target> </Target>
</targetSelectedWithDropDown> </targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-10-25T03:05:37.506900100Z" /> <timeTargetWasSelectedWithDropDown value="2022-10-21T10:44:09.320658400Z" />
</component> </component>
</project> </project>

@ -4,16 +4,18 @@
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<option name="delegatedBuild" value="false" />
<option name="testRunner" value="GRADLE" /> <option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" /> <option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$PROJECT_DIR$/../gradle-6.6.1" />
<option name="gradleJvm" value="11" />
<option name="modules"> <option name="modules">
<set> <set>
<option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" /> <option value="$PROJECT_DIR$/app" />
</set> </set>
</option> </option>
<option name="delegatedBuild" value="false" />
</GradleProjectSettings> </GradleProjectSettings>
</option> </option>
</component> </component>

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android API 33, extension level 3 Platform" project-jdk-type="Android SDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

@ -29,9 +29,9 @@ android {
dependencies { dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1' implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.5.0' implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3' implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation files('D:\\FruitsProject\\app\\src\\main\\res\\aip-java-sdk-4.16.9.jar') implementation files('D:\\FruitsProject\\app\\src\\main\\res\\aip-java-sdk-4.16.9.jar')
implementation files('D:\\FruitsProject\\app\\src\\main\\res\\json-20160810.jar') implementation files('D:\\FruitsProject\\app\\src\\main\\res\\json-20160810.jar')
implementation files('D:\\FruitsProject\\app\\src\\main\\res\\slf4j-api-1.7.25.jar') implementation files('D:\\FruitsProject\\app\\src\\main\\res\\slf4j-api-1.7.25.jar')

@ -1,4 +1,4 @@
package com.example.Fruits; package com.example.ceshi;
import android.content.Context; import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.platform.app.InstrumentationRegistry;

@ -1,11 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="com.example.Fruits"> package="com.example.ceshi">
<!--//访问电话状态--> <!--//访问电话状态-->
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!--//允许全部网络访问--> <!--//允许全部网络访问-->
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<!--//获取网络信息状态--> <!--//获取网络信息状态-->
@ -14,12 +12,6 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<!--//写入-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE\"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>
<application <application
android:allowBackup="true" android:allowBackup="true"
@ -30,14 +22,12 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Ceshi" android:theme="@style/Theme.Ceshi"
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
tools:targetApi="31"> tools:targetApi="31">
<meta-data android:name="6H2WBMm7uYGYD2dKqH46EMrM" android:value="BoSgG8lqIcHfprxnNa2saHiwI5x3o1vP">
</meta-data>
<activity <activity
android:name="com.example.Fruits.MainActivity" android:name=".first"
android:exported="true"> android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
@ -45,12 +35,11 @@
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name="com.example.Fruits.WordSearchActivity"/> <activity android:name=".second"/>
<activity android:name="com.example.Fruits.PictureSearchActivity"/> <activity android:name=".four"/>
<activity android:name="com.example.Fruits.CollectActivity"/> <activity android:name=".collection"/>
<activity android:name="com.example.Fruits.WebViewActivity"/> <activity android:name=".WebViewActivity"/>
<activity android:name=".get"/>
<provider <provider
android:authorities="com.example.takephoto.fileprovider" android:authorities="com.example.takephoto.fileprovider"
android:name="androidx.core.content.FileProvider" android:name="androidx.core.content.FileProvider"

@ -1,4 +1,4 @@
package com.transfer; package com.baidu.ai.aip;
import org.json.JSONObject; import org.json.JSONObject;

@ -1,5 +1,5 @@
package com.transfer; package com.baidu.ai.aip;
import com.baidu.ai.aip.utils.HttpUtil; import com.baidu.ai.aip.utils.HttpUtil;
import com.baidu.ai.aip.utils.GsonUtils; import com.baidu.ai.aip.utils.GsonUtils;
@ -23,7 +23,7 @@ public class ImgCombination {
public String imgCombinatio(){ public String imgCombinatio(){
return "QEEEEEE"; return "QEEEEEE";
} }
public String imgCombination() { public String imgCombination() {
// 请求url // 请求url
String url = "https://aip.baidubce.com/api/v1/solution/direct/imagerecognition/combination"; String url = "https://aip.baidubce.com/api/v1/solution/direct/imagerecognition/combination";
try { try {
@ -40,7 +40,7 @@ public class ImgCombination {
// 注意这里仅为了简化编码每一次请求都去获取access_token线上环境access_token有过期时间 客户端可自行缓存,过期后重新获取。 // 注意这里仅为了简化编码每一次请求都去获取access_token线上环境access_token有过期时间 客户端可自行缓存,过期后重新获取。
String accessToken = "24.bb5baa6f79502180928d105dd8ea46c8.2592000.1668576873.282335-27944955"; String accessToken = "24.bb5baa6f79502180928d105dd8ea46c8.2592000.1668576873.282335-27944955";
String result =HttpUtil.post(url, accessToken, "application/json", param); String result = HttpUtil.post(url, accessToken, "application/json", param);
//System.out.println("**************************"); //System.out.println("**************************");
//System.out.println(result); //System.out.println(result);
//System.out.println("**************************"); //System.out.println("**************************");
@ -48,10 +48,7 @@ public class ImgCombination {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return "Error1"; return "FORS";
} }
// public static void main(String[] args) {
// ImgCombination.imgCombination();
// }
} }

@ -1,23 +1,16 @@
package com.transfer; package com.baidu.ai.aip;
import android.graphics.Bitmap;
import com.baidu.ai.aip.utils.Base64Util; import com.baidu.ai.aip.utils.Base64Util;
import com.baidu.ai.aip.utils.FileUtil; import com.baidu.ai.aip.utils.FileUtil;
import com.baidu.ai.aip.utils.HttpUtil; import com.baidu.ai.aip.utils.HttpUtil;
import java.net.URI;
import java.net.URLEncoder; import java.net.URLEncoder;
/** /**
* *
*/ */
public class Ingredient { public class Ingredient {
String aa;
public Ingredient(String a) {
aa=a;
}
/** /**
* *
@ -28,23 +21,23 @@ public class Ingredient {
* https://ai.baidu.com/file/470B3ACCA3FE43788B5A963BF0B625F3 * https://ai.baidu.com/file/470B3ACCA3FE43788B5A963BF0B625F3
* *
*/ */
public String ingredient() { public static String ingredient() {
// 请求url // 请求url
String url = "https://aip.baidubce.com/rest/2.0/image-classify/v1/classify/ingredient"; String url = "https://aip.baidubce.com/rest/2.0/image-classify/v1/classify/ingredient";
try { try {
// 本地文件路径 // 本地文件路径
//String filePath = "手机存储/Pictures/p2.jpg"; String filePath = "D:/li.jpg";
byte[] imgData = FileUtil.readFileByBytes(aa); byte[] imgData = FileUtil.readFileByBytes(filePath);
String imgStr = Base64Util.encode(imgData); String imgStr = Base64Util.encode(imgData);
String imgParam = URLEncoder.encode(imgStr, "UTF-8"); String imgParam = URLEncoder.encode(imgStr, "UTF-8");
String param = "image=" + imgParam; String param = "image=" + imgParam;
// 注意这里仅为了简化编码每一次请求都去获取access_token线上环境access_token有过期时间 客户端可自行缓存,过期后重新获取。 // 注意这里仅为了简化编码每一次请求都去获取access_token线上环境access_token有过期时间 客户端可自行缓存,过期后重新获取。
//String accessToken = "24.29d61c398f70469aa1b17124092051de.2592000.1668944414.282335-27944955"; String accessToken = "24.bb5baa6f79502180928d105dd8ea46c8.2592000.1668576873.282335-27944955";
AuthService auth = new AuthService(); // AuthService auth = new AuthService();
String accessToken = auth.getAuth(); // String accessToken = auth.getAuth();
String result = HttpUtil.post(url, accessToken, param); String result = HttpUtil.post(url, accessToken, param);
System.out.println(result); System.out.println(result);
@ -55,7 +48,7 @@ public class Ingredient {
return null; return null;
} }
// public static void main(String[] args) { public static void main(String[] args) {
// Ingredient.ingredient(); Ingredient.ingredient();
// } }
} }

@ -0,0 +1,21 @@
package com.baidu.ai.aip;
import com.baidu.ai.aip.ImgCombination;
import com.example.ceshi.four;
public class ToIngredient{
public static String name_odds="AAAAAAAAAAAA";
public static void main(String[] args) {
ImgCombination img=new ImgCombination();
String str = img.imgCombination();
String name=str.substring(str.indexOf("name")+7,str.indexOf("\"}"));
String odds=str.substring(str.indexOf("score")+7,str.indexOf(","));
name_odds="aaaa";//"有"+odds.substring(0,4)+"的概率是"+name;
System.out.println("有"+odds.substring(0,4)+"的概率是"+name);
}
public String x(){
name_odds="bbbb";
return name_odds;
}
}

@ -59,7 +59,7 @@ public class HttpUtil {
Map<String, List<String>> headers = connection.getHeaderFields(); Map<String, List<String>> headers = connection.getHeaderFields();
// 遍历所有的响应头字段 // 遍历所有的响应头字段
for (String key : headers.keySet()) { for (String key : headers.keySet()) {
//System.err.println(key + "--->" + headers.get(key)); System.err.println(key + "--->" + headers.get(key));
} }
// 定义 BufferedReader输入流来读取URL的响应 // 定义 BufferedReader输入流来读取URL的响应
BufferedReader in = null; BufferedReader in = null;
@ -71,7 +71,7 @@ public class HttpUtil {
result += getLine; result += getLine;
} }
in.close(); in.close();
//System.err.println("result:" + result); System.err.println("result:" + result);
return result; return result;
} }
} }

@ -1,4 +1,4 @@
package com.example.Fruits; package com.example.ceshi;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
@ -8,19 +8,14 @@ import android.webkit.WebViewClient;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
public class WebViewActivity extends AppCompatActivity { public class WebViewActivity extends AppCompatActivity {
private WebView mWebView; public WebView mWebView;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.web_view_activity); setContentView(R.layout.activity_web_view);
mWebView = (WebView) findViewById(R.id.web_view); mWebView = (WebView) findViewById(R.id.web_view);
Intent intent = getIntent(); Intent intent = getIntent();
String url = null;//"https://baike.baidu.com/item/"+intent.getStringExtra("url"); //"https://baidu.com/";// String url = "https://baidu.com//";//intent.getStringExtra("url");
//try {
url = "https://baike.baidu.com/item/"+intent.getStringExtra("url")+"?&ie=utf-8&oe=UTF-8&wd=";//+ URLEncoder.encode("西瓜","UTF-8");
//} catch (UnsupportedEncodingException e) {
// e.printStackTrace();
// }
mWebView.loadUrl(url); mWebView.loadUrl(url);
mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebViewClient(){ mWebView.setWebViewClient(new WebViewClient(){

@ -0,0 +1,15 @@
package com.example.ceshi;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class collection extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.collview);
}
}

@ -1,23 +1,25 @@
package com.example.Fruits; package com.example.ceshi;
import android.annotation.SuppressLint;
import android.content.Intent; import android.content.Intent;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
public class MainActivity extends AppCompatActivity { public class first extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity); setContentView(R.layout.firstview);
//获取按钮 //获取按钮
Button button = findViewById(R.id.button); Button button = findViewById(R.id.button);
// Button button2 = findViewById(R.id.button2); // Button button2 = findViewById(R.id.button2);
Button button3 = findViewById(R.id.button3); Button button3 = findViewById(R.id.button3);
Button button4 = findViewById(R.id.button4); Button button4 = findViewById(R.id.button4);
Button button5 = findViewById(R.id.test);
//按钮进行监听 //按钮进行监听
button.setOnClickListener(new View.OnClickListener() { button.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -25,17 +27,27 @@ public class MainActivity extends AppCompatActivity {
//监听按钮,如果点击,就跳转 //监听按钮,如果点击,就跳转
Intent intent = new Intent(); Intent intent = new Intent();
//前一个MainActivity.this是目前页面后面一个是要跳转的下一个页面 //前一个MainActivity.this是目前页面后面一个是要跳转的下一个页面
intent.setClass(MainActivity.this, WordSearchActivity.class); intent.setClass(first.this,second.class);
startActivity(intent); startActivity(intent);
} }
}); });
// button2.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// //监听按钮,如果点击,就跳转
// Intent intent = new Intent();
// //前一个MainActivity.this是目前页面后面一个是要跳转的下一个页面
// intent.setClass(first.this,third.class);
// startActivity(intent);
// }
// });
button3.setOnClickListener(new View.OnClickListener() { button3.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
//监听按钮,如果点击,就跳转 //监听按钮,如果点击,就跳转
Intent intent = new Intent(); Intent intent = new Intent();
//前一个MainActivity.this是目前页面后面一个是要跳转的下一个页面 //前一个MainActivity.this是目前页面后面一个是要跳转的下一个页面
intent.setClass(MainActivity.this, PictureSearchActivity.class); intent.setClass(first.this, four.class);
startActivity(intent); startActivity(intent);
} }
}); });
@ -45,7 +57,17 @@ public class MainActivity extends AppCompatActivity {
//监听按钮,如果点击,就跳转 //监听按钮,如果点击,就跳转
Intent intent = new Intent(); Intent intent = new Intent();
//前一个MainActivity.this是目前页面后面一个是要跳转的下一个页面 //前一个MainActivity.this是目前页面后面一个是要跳转的下一个页面
intent.setClass(MainActivity.this, CollectActivity.class); intent.setClass(first.this, collection.class);
startActivity(intent);
}
});
button5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//监听按钮,如果点击,就跳转
Intent intent = new Intent();
//前一个MainActivity.this是目前页面后面一个是要跳转的下一个页面
intent.setClass(first.this, get.class);
startActivity(intent); startActivity(intent);
} }
}); });

@ -0,0 +1,118 @@
package com.example.ceshi;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.FileProvider;
import com.baidu.ai.aip.ImgCombination;
import com.baidu.ai.aip.ToIngredient;
import com.baidu.ai.aip.Ingredient;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
public class four extends AppCompatActivity {
final int TAKE_PHOTO=1;
ImageView iv_photo;
Uri imageUri;
TextView t1;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.fourview);
Button btn_1=findViewById(R.id.btn_takephoto);
iv_photo=findViewById(R.id.img_photo);
t1=findViewById(R.id.textView11);
//ToIngredient ii= new ToIngredient();
ImgCombination img=new ImgCombination();
//String str11 = img.imgCombination();
Ingredient a=new Ingredient();
// "{\"result_num\":5,\"result\":[{\"score\":0.6307158,\"name\":\"砀山酥梨\"},{\"score\":0.19453917,\"name\":\"砀山梨\"},{\"score\":0.06309598,\"name\":\"北丰梨\"},{\"score\":0.062131744,\"name\":\"雪梨\"},{\"score\":0.0255048,\"name\":\"梨\"}],\"log_id\":1582269295467236738}\n";
//t1.setText("A"+str11+"B");
t1.setText("###"+Ingredient.ingredient());
btn_1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
File output=new File(getExternalCacheDir(),"output_image.jpg");
try {
if (output.exists()){
output.delete();
}
output.createNewFile();
}catch (IOException e){
e.printStackTrace();
}
if (Build.VERSION.SDK_INT>=24){
//图片的保存路径
imageUri= FileProvider.getUriForFile(four.this,"com.example.takephoto.fileprovider",output);
}
else { imageUri=Uri.fromFile(output);}
//跳转界面到系统自带的拍照界面
Intent intent=new Intent("android.media.action.IMAGE_CAPTURE");
intent.putExtra(MediaStore.EXTRA_OUTPUT,imageUri);
startActivityForResult(intent,TAKE_PHOTO);
}
});
// String str = ImgCombination.imgCombination();
// String name=str.substring(str.indexOf("name")+7,str.indexOf("\"}"));
// String odds=str.substring(str.indexOf("score")+7,str.indexOf(","));
}
@Override
protected void onActivityResult(int requestCode,int resultCode,Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode){
case TAKE_PHOTO:
if (resultCode==RESULT_OK){
// 使用try让程序运行在内报错
try {
//将图片保存
Bitmap bitmap= BitmapFactory.decodeStream(getContentResolver().openInputStream(imageUri));
iv_photo.setImageBitmap(bitmap);
//ToIngredient to_in=new ToIngredient();
ImgCombination img1=new ImgCombination();
String str1 =img1.imgCombination();
//// ToIngredient ii= new ToIngredient();
// String aa=ii.x();
//String name=str.substring(str.indexOf("name")+7,str.indexOf("\"}"));
//TextView t1=()findViewById(R.id.textView11);
//t1.setText(str1);
}catch (FileNotFoundException e){
e.printStackTrace();
}
}
break;
default:break;
}
}
}

@ -0,0 +1,100 @@
package com.example.ceshi;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;d
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.TextView;
public class get extends Activity {
// textview
private TextView mTextView;
// handler线程
private Handler mHandler = new Handler() {
public void handleMessage(android.os.Message msg) {
mTextView.setText((String) msg.obj);
};
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.get);
// 绑定id
mTextView = (TextView) findViewById(R.id.a);
}
// 联网
private void getHttp() {
InputStream stream = null;
InputStreamReader re = null;
BufferedReader reader = null;
try {
// 找水源
URL url = new URL("http://www.taobao.com");
// 建立总闸
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
// 建立水道
stream = conn.getInputStream();
// 捕鱼
// 小渔网
re = new InputStreamReader(stream);
// 大渔网
reader = new BufferedReader(re);
// 捞鱼
// 大水桶
String len = "";
// 小水桶
String temp = "";
while ((temp = reader.readLine()) != null) {
len += temp;
}
// 更新UI
Message sg = new Message();
sg.obj = len;
mHandler.sendMessage(sg);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
// 晒网,关闭资源
try {
if (reader != null) {
reader.close();
}
if (re != null) {
re.close();
}
if (stream != null) {
stream.close();
}
} catch (Exception e2) {
}
}
}
// 按钮监听
public void aaa(View v) {
//新建一个线程
new Thread() {
public void run() {
getHttp();
};
}.start();
}
}

@ -1,4 +1,4 @@
package com.example.Fruits; package com.example.ceshi;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
@ -8,21 +8,21 @@ import android.widget.EditText;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
public class WordSearchActivity extends AppCompatActivity { public class second extends AppCompatActivity {
private EditText mEditUrl; private EditText mEditUrl;
private Button mBtnOpen; private Button mBtnOpen;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.word_search_activity); setContentView(R.layout.secondview);
mEditUrl = (EditText) findViewById(R.id.edit_url); mEditUrl = (EditText) findViewById(R.id.edit_url);
mBtnOpen = (Button) findViewById(R.id.btn_open); mBtnOpen = (Button) findViewById(R.id.btn_open);
mBtnOpen.setOnClickListener(new View.OnClickListener() { mBtnOpen.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(WordSearchActivity.this, WebViewActivity.class); Intent intent = new Intent(second.this, WebViewActivity.class);
String url = mEditUrl.getText().toString(); String url = "http://www.baidu.com";//mEditUrl.getText().toString();
intent.putExtra("url", url); intent.putExtra("url", url);
startActivity(intent); startActivity(intent);
} }

Before

Width:  |  Height:  |  Size: 649 B

After

Width:  |  Height:  |  Size: 649 B

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="@+id/web_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteX="61dp"
tools:layout_editor_absoluteY="86dp">
<Button
android:id="@+id/button8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="307dp"
android:layout_y="666dp"
android:background="@android:color/holo_orange_light"
android:text="收藏" />
</WebView>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".first">
<TextView
android:id="@+id/five"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="我的收藏"
android:textSize="25dp"
android:textColor="#663399"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintVertical_bias="0.499"/>
<SearchView
android:layout_width="407dp"
android:layout_height="100dp" tools:layout_editor_absoluteY="1dp" tools:layout_editor_absoluteX="1dp"
tools:ignore="MissingConstraints"/>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -5,31 +5,29 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity"> tools:context=".first">
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<TextView <TextView
android:id="@+id/one" android:id="@+id/one"
android:layout_width="wrap_content" android:layout_width="200dp"
android:layout_height="wrap_content" android:layout_height="100dp"
android:layout_alignParentStart="true"
android:layout_marginStart="123dp" android:layout_marginStart="137dp"
android:layout_marginTop="18dp" android:layout_marginTop="50dp"
android:gravity="center"
android:text="果识" android:text="果识"
android:textSize="75dp" /> android:textSize="75dp" />
<Button <Button
android:id="@+id/button3" android:id="@+id/button3"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="50dp" android:layout_height="50dp"
tools:ignore="MissingConstraints" tools:ignore="MissingConstraints"
android:text="水果鉴定" android:text="水果鉴定"
android:layout_below="@+id/one" android:layout_below="@+id/one"
android:layout_marginTop="170dp" android:layout_marginTop="170dp" app:backgroundTint="#4CAF50"/>
app:backgroundTint="#4CAF50"/>
<Button <Button
android:id="@+id/button" android:id="@+id/button"
@ -42,12 +40,18 @@
<Button <Button
android:text="我的收藏" android:text="我的收藏"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content" android:id="@+id/button4" app:backgroundTint="#FFB13B"
android:id="@+id/button4"
app:backgroundTint="#FFB13B"
android:layout_below="@+id/one" android:layout_below="@+id/one"
android:layout_marginTop="240dp"/> android:layout_marginTop="240dp"/>
</RelativeLayout>
<Button
android:id="@+id/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button4"
android:layout_marginBottom="-180dp"
android:text="test1" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

@ -5,7 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:context=".PictureSearchActivity"> tools:context=".four">
<Button <Button
android:id="@+id/btn_takephoto" android:id="@+id/btn_takephoto"
@ -24,12 +24,9 @@
android:id="@+id/textView11" android:id="@+id/textView11"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="A"
android:layout_below="@+id/img_photo" android:layout_below="@+id/img_photo"
android:layout_gravity="center" android:layout_marginTop="34dp" app:backgroundTint="#4CAF50"/>
android:layout_marginTop="19dp"
android:text="点击拍照,即可识别!"
android:textColor="@color/red"
app:backgroundTint="#4CAF50" />
/> />

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<Button
android:id="@+id/a12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="获取"
android:onClick="aaa"
/>
<ScrollView
android:layout_below="@id/a12"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="获取网址内容" />
</ScrollView>
</RelativeLayout>

@ -4,32 +4,41 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity"> tools:context=".first">
<TextView
android:id="@+id/five"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="349dp"
android:text="水果百科"
android:textColor="#663399"
android:textSize="25dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/edit_url"
app:layout_constraintVertical_bias="0.499" />
<EditText <EditText
android:id="@+id/edit_url" android:id="@+id/edit_url"
android:layout_width="475dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="200dp"
android:layout_marginBottom="59dp"
android:layout_marginTop="88dp"
android:layout_marginBottom="57dp"
app:layout_constraintBottom_toTopOf="@+id/btn_open" app:layout_constraintBottom_toTopOf="@+id/btn_open"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<Button <Button
android:id="@+id/btn_open" android:id="@+id/btn_open"
android:layout_width="416dp" android:layout_width="wrap_content"
android:layout_height="50dp" android:layout_height="wrap_content"
android:layout_marginBottom="437dp" android:layout_marginBottom="573dp"
android:text="Button"
android:text="搜索"
app:backgroundTint="#4CAF50"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/edit_url" /> app:layout_constraintTop_toBottomOf="@+id/edit_url" />

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

@ -7,5 +7,4 @@
<color name="teal_700">#FF018786</color> <color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color> <color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color> <color name="white">#FFFFFFFF</color>
<color name="red">#FF0000</color>
</resources> </resources>

@ -1,4 +1,4 @@
package com.example.Fruits; package com.example.ceshi;
import org.junit.Test; import org.junit.Test;

@ -7,4 +7,4 @@ plugins {
task clean(type: Delete) { task clean(type: Delete) {
delete rootProject.buildDir delete rootProject.buildDir
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save