Javascript 使用sendIntent.putExtras(bundle)的空页面,页面未填充Android studio
我试图通过邮件或蓝牙等方式发送一些东西,但效果不太好。 我希望看到这样的文本: “呼吸率:0.2.0 5.0 16.0”。。。 为此,我实现了一个按钮和Resut.java之类的东西。当我尝试点击按钮并选择电子邮件时,应用程序打开一封邮件,文本仅为“呼吸频率” 单击此处按钮:Javascript 使用sendIntent.putExtras(bundle)的空页面,页面未填充Android studio,javascript,java,android,Javascript,Java,Android,我试图通过邮件或蓝牙等方式发送一些东西,但效果不太好。 我希望看到这样的文本: “呼吸率:0.2.0 5.0 16.0”。。。 为此,我实现了一个按钮和Resut.java之类的东西。当我尝试点击按钮并选择电子邮件时,应用程序打开一封邮件,文本仅为“呼吸频率” 单击此处按钮: SRR.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
SRR.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
Bundle bundle = new Bundle();
bundle.putDoubleArray("TryThis",plot_array);
sendIntent.putExtras(bundle);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Respiration Rate: " );
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
}
});
result.java:
package com.google.android.gms.samples.vision.face.rPPG;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.bluetooth.le.AdvertiseData;
import android.bluetooth.le.AdvertiseSettings;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.ParcelUuid;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.series.DataPoint;
import com.jjoe64.graphview.series.LineGraphSeries;
import com.jjoe64.graphview.series.PointsGraphSeries;
import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;
public class RespirationResult extends AppCompatActivity {
private String Date;
int RR;
int il_risultato;
double [] plot_array;
int[] intArray;
DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
java.util.Date today = Calendar.getInstance().getTime();
private String[] RRtoSent=new String[300];
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_respiration_result);
Date = df.format(today);
TextView RRR = (TextView) this.findViewById(R.id.RRR);
ImageButton SRR = (ImageButton)this.findViewById(R.id.SendRR);
//-------------------------------------------------------------------------risutato
Bundle b = getIntent().getExtras();
double result = b.getDouble("key");
plot_array=b.getDoubleArray("array");
il_risultato=(int) Math.round(result);
RRR.setText(String.valueOf(il_risultato)); //prima era RR, da mettere successivamente
RRtoSent = new String[plot_array.length];
for (int i = 0; i < RRtoSent.length; i++) {
RRtoSent[i] = String.valueOf(plot_array[i]);
}
//grafico
GraphView graph;
LineGraphSeries<DataPoint> series; //an Object of the PointsGraphSeries for plotting scatter graphs
graph = (GraphView) findViewById(R.id.graphico);
series= new LineGraphSeries<>(data()); //initializing/defining series to get the data from the method 'data()'
graph.addSeries(series); //adding the series to the GraphView
//series.setShape(PointsGraphSeries.Shape.POINT);
// activate horizontal and vertical zooming and scrolling
graph.getViewport().setScalableY(true);
graph.getGridLabelRenderer().setGridColor(Color.DKGRAY);
graph.getGridLabelRenderer().setHorizontalLabelsColor(Color.DKGRAY);
graph.getGridLabelRenderer().setVerticalLabelsColor(Color.DKGRAY);
// graph.setTitle("Respiration Rate/min");
graph.getGridLabelRenderer().setHorizontalAxisTitle("time(sec)");
graph.getGridLabelRenderer().setVerticalAxisTitle("RR");
// set manual X bounds
graph.getViewport().setXAxisBoundsManual(true);
graph.getViewport().setMinX(0.5);
graph.getViewport().setMaxX(100);
SRR.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
Bundle bundle = new Bundle();
bundle.putDoubleArray("TryThis",plot_array);
sendIntent.putExtras(bundle);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Respiration Rate: " );
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
}
});
}
public DataPoint[] data(){
DataPoint[] values = new DataPoint[plot_array.length]; //creating an object of type DataPoint[] of size 'n'
for(int i=0;i<plot_array.length;i++){
DataPoint v = new DataPoint(i,plot_array[i]);
values[i] = v;
}
return values;
}
@Override
public void onBackPressed() {
Intent i = new Intent(RespirationResult.this, SplashScreen.class);
startActivity(i);
finish();
super.onBackPressed();
}
}
package com.google.android.gms.samples.vision.face.rPPG;
导入android.bluetooth.BluetoothAdapter;
导入android.bluetooth.BluetoothManager;
导入android.bluetooth.le.AdvertiseData;
导入android.bluetooth.le.AdvertiseSettings;
导入android.content.Intent;
导入android.graphics.Color;
导入android.os.Bundle;
导入android.os.parceluid;
导入android.support.v7.app.AppActivity;
导入android.view.view;
导入android.widget.ImageButton;
导入android.widget.TextView;
导入android.widget.Toast;
导入com.jjoe64.graphview.graphview;
导入com.jjoe64.graphview.series.DataPoint;
导入com.jjoe64.graphview.series.LineGraphSeries;
导入com.jjoe64.graphview.series.PointsGraphSeries;
导入java.io.Serializable;
导入java.text.DateFormat;
导入java.text.simpleDataFormat;
导入java.util.ArrayList;
导入java.util.Calendar;
导入java.util.Collections;
导入java.util.List;
公共类呼吸结果扩展了AppCompatActivity{
私有字符串日期;
int-RR;
国际劳工组织;
双[]点阵;
int[]intArray;
DateFormat df=新的简化格式(“MM/dd/yyyy HH:MM:ss”);
java.util.Date today=Calendar.getInstance().getTime();
私有字符串[]RRtoSent=新字符串[300];
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u result);
日期=df.format(今天);
TextView RRR=(TextView)this.findViewById(R.id.RRR);
ImageButton SRR=(ImageButton)this.findViewById(R.id.SendRR);
//-------------------------------------------------------------------------里苏塔托
Bundle b=getIntent().getExtras();
双结果=b.getDouble(“键”);
plot_array=b.getDoubleArray(“数组”);
il_risultato=(int)数学四舍五入(结果);
RRR.setText(String.valueOf(il_risultato));//prima era RR,da mettere successivatione
RRtoSent=新字符串[plot_array.length];
for(int i=0;i 对于(int i=0;i,这是因为您想要显示的内容必须是额外文本的一部分:
sendIntent.putExtra(Intent.EXTRA_文本,“要在此处打印的所有内容”);
因此,您必须使用数据构建一个字符串,然后使用完整的字符串创建额外的字符串。这是因为您要显示的内容必须是额外文本的一部分:
sendIntent.putExtra(Intent.EXTRA_文本,“要在此处打印的所有内容”);
因此,您必须使用数据构建一个字符串,然后使用完整的字符串创建额外的字符串。From
公共静态最终字符串额外文本
与意图关联的常量字符序列,用于
操作\u SEND以提供要发送的文字数据。请注意,这可能会
是已设置样式的CharSequence,因此必须使用Bundle.getCharSequence()来
找回它
因此,在调用电子邮件应用程序之前,您应该首先将双数组转换为字符串
步骤1:编写一个将双数组转换为字符串的方法
private String convertDoubleArrayToString(double[] array) {
StringBuilder sb = new StringBuilder();
for (double number: array) {
sb.append(number).append(" ");
}
return sb.toString();
}
步骤2:将代码更改为
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Respiration Rate: " + convertDoubleArrayToString(plot_array));
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
从
公共静态最终字符串额外文本
与意图关联的常量字符序列,用于
操作\u SEND以提供要发送的文字数据。请注意,这可能会
是已设置样式的CharSequence,因此必须使用Bundle.getCharSequence()来
找回它
所以你应该