gpt4 book ai didi

java - android 无法从二维码中提取数据

转载 作者:行者123 更新时间:2023-12-02 10:41:38 25 4
gpt4 key购买 nike

扫描二维码后,应用程序将获取 Activity 标题、开始日期、结束日期和地点。
(html代码: encodeURIComponent(txt1 + "\n"+ txt2 + "\n"+ txt3 + "\n"+ txt4))

以及如何将这些值放入此代码中:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if(result != null){
if(result.getContents()==null){
Toast.makeText(this, "You Cancelled the Scanning", Toast.LENGTH_LONG).show();
}
else {
Calendar cal = Calendar.getInstance();
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("beginTime", ?);
intent.putExtra("allDay", true);
intent.putExtra("rrule", "FREQ=YEARLY");
intent.putExtra("endTime", ?);
intent.putExtra("title", ?);
intent.putExtra("eventLocation", ?);
startActivity(intent);
}
}
else{
super.onActivityResult(requestCode, resultCode, data);
}
}

最佳答案

您可以使用String.split()将字符串分成子字符串。这将为您提供一个可以传递给 Intent 的字符串数组。

        String result = "Event title <br> start date <br> end date <br> location"
String[] info = result.split("<br>");
Calendar cal = Calendar.getInstance();
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("beginTime", info[1].trim());
intent.putExtra("allDay", true);
intent.putExtra("rrule", "FREQ=YEARLY");
intent.putExtra("endTime", info[2].trim());
intent.putExtra("title", info[0].trim());
intent.putExtra("eventLocation", info[3].trim());
startActivity(intent);

关于java - android 无法从二维码中提取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52887229/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com