develop
z15755800224@163.com 3 years ago
parent 3d01465ced
commit a295b4c140

Binary file not shown.

@ -2,8 +2,19 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.ceshi">
<!--//访问电话状态-->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!--//允许全部网络访问-->
<uses-permission android:name="android.permission.INTERNET" />
<!--//获取网络信息状态-->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!--//获取当前WiFi接入的状态以及WLAN热点的信息-->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
@ -12,7 +23,10 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Ceshi"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<meta-data android:name="6H2WBMm7uYGYD2dKqH46EMrM" android:value="BoSgG8lqIcHfprxnNa2saHiwI5x3o1vP">
</meta-data>
<activity
android:name=".first"
android:exported="true">
@ -23,9 +37,9 @@
</intent-filter>
</activity>
<activity android:name=".second"/>
<activity android:name=".four"/>
<activity android:name=".collection"/>
<activity android:name=".WebViewActivity"/>
<provider
android:authorities="com.example.takephoto.fileprovider"
android:name="androidx.core.content.FileProvider"
@ -35,10 +49,9 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"/>
</provider>
</application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>

@ -20,6 +20,9 @@ public class ImgCombination {
* https://ai.baidu.com/file/470B3ACCA3FE43788B5A963BF0B625F3
*
*/
public String imgCombinatio(){
return "QEEEEEE";
}
public String imgCombination() {
// 请求url
String url = "https://aip.baidubce.com/api/v1/solution/direct/imagerecognition/combination";
@ -45,7 +48,7 @@ public class ImgCombination {
} catch (Exception e) {
e.printStackTrace();
}
return null;
return "FORS";
}
}

@ -4,14 +4,18 @@ 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(","));
String name_odds="有"+odds.substring(0,4)+"的概率是"+name;
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;
}
}

@ -0,0 +1,32 @@
package com.example.ceshi;
import android.content.Intent;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.appcompat.app.AppCompatActivity;
public class WebViewActivity extends AppCompatActivity {
private WebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
mWebView = (WebView) findViewById(R.id.web_view);
Intent intent = getIntent();
String url = "http://www.baidu.com";//intent.getStringExtra("url");
mWebView.loadUrl(url);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebViewClient(){
});
}
@Override
public void onBackPressed() {
if (mWebView != null && mWebView.canGoBack()){
mWebView.goBack();
}else {
super.onBackPressed();
}
}
}

@ -18,21 +18,38 @@ 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) {
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
@ -65,6 +82,9 @@ public class four extends AppCompatActivity {
}
@Override
protected void onActivityResult(int requestCode,int resultCode,Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode){
@ -84,8 +104,8 @@ public class four extends AppCompatActivity {
//// 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);
//TextView t1=()findViewById(R.id.textView11);
//t1.setText(str1);
}catch (FileNotFoundException e){
e.printStackTrace();
}

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

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
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"/>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,27 +1,46 @@
<?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">
<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"
android:background="@drawable/green" tools:layout_editor_absoluteY="1dp" tools:layout_editor_absoluteX="1dp"
tools:ignore="MissingConstraints"/>
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
android:id="@+id/edit_url"
android:layout_width="0dp"
android:layout_height="200dp"
android:layout_marginBottom="59dp"
app:layout_constraintBottom_toTopOf="@+id/btn_open"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/btn_open"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="573dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/edit_url" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>
Loading…
Cancel
Save