我有一个软键盘作为调用活动的inputmethodservice。按下按钮并激活扫描仪。扫描程序活动捕获一组数据,然后将数据返回到inputmethodservice以填充浏览器上的文本字段。
如何将活动的扫描值返回到inputmethodservice以及如何设置为getCurrentInputConnection()。commitText(data,1)? 以下snnipet用于调用scannerActivity
final Intent intent = new Intent(Intent.ACTION_MAIN, null);
final ComponentName cn = new ComponentName(
"com.example.android.softkeyboard",
"com.example.android.softkeyboard.ScannerActivity");
intent.setComponent(cn);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
答案 0 :(得分:1)
你不应该使用startActivityForResult吗?
答案 1 :(得分:0)
use this way
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
startActivityForResult(intent, 0);
public void onActivityResult(int requestCode, int resultCode, Intent intent)
{
if(resultCode == 0)
{
if (resultCode == RESULT_OK)
{
String contents = intent.getStringExtra("your string");
}
}
};
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
startActivityForResult(intent, 0);
public void onActivityResult(int requestCode, int resultCode, Intent intent)
{
if(resultCode == 0)
{
if (resultCode == RESULT_OK)
{
String contents = intent.getStringExtra("your string");
}
}
};