我的phonegap应用程序使用zxing条码扫描器。我aso从zxing安装一个演示程序(barcodescanner)。现在,在我的phonegap应用程序中,当我打电话给条码扫描器时,android问我选择哪个应用程序来执行此操作(我的应用程序和zxing barcodescanner)。如何避免这种情况?我不希望android问我这样的用户android intent call without inquiry
0
A
回答
0
如果您还没有更改任何代码,默认情况下Zxing注册以下意图。
<action android:name="com.phonegap.plugins.barcodescanner.SCAN" />
您可以通过执行以下更改来更改此选项,以使其更具体。
// in BarcodeScanner.java plugin file
public void scan() {
// changed to custom intent
Intent intentScan = new Intent("com.dhaval.phonegap.plugins.barcodescanner.SCAN");
intentScan.addCategory(Intent.CATEGORY_DEFAULT);
this.ctx.startActivityForResult((Plugin) this, intentScan, REQUEST_CODE);
}
public void encode(String type, String data) {
// changed to custom intent
Intent intentEncode = new Intent("com.dhaval.phonegap.plugins.barcodescanner.ENCODE");
intentEncode.putExtra("ENCODE_TYPE", type);
intentEncode.putExtra("ENCODE_DATA", data);
this.ctx.startActivity(intentEncode);
}
在你的应用程序AndroidManifest.xml文件,意图过滤字符串更改为BarcodeScanner.java使用您的自定义字符串文件之上
<activity android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="com.dhaval.phonegap.plugins.barcodescanner.SCAN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.google.zxing.client.android.encode.EncodeActivity"
android:label="@string/share_name">
<intent-filter>
<action android:name="com.dhaval.phonegap.plugins.barcodescanner.ENCODE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
0
您可以拨打setPackage()
在Intent
您发送给指挥它只有一个可能的应用程序。在这里你可以设置为"com.google.zxing.client.android"
。
相关问题
- 1. Android SMS Via Intent Without Chooser
- 2. php soap call without xsi:type
- 3. system()to c#without call cmd.exe
- 4. asp.net dropdownlist ajax call without ajaxtoolkit
- 5. Call second Activity Android
- 6. 在Android上处理双卡,使用CALL intent
- 7. 蛋糕PHP总是返回0 $ this-> Layout-> boolYesNo($ inquiry ['Inquiry'] ['read']
- 8. Android onActivityResult()with Intent
- 9. Android StartAcitivty()with intent
- 10. 是Android不支持USSD CALL?
- 11. android add extra and call programmatically
- 12. Android Viewpager Call Webservice
- 13. Android SherlockFragmentActivity call SherlockFragment
- 14. Tango Without Android?
- 15. Android ORMLite without context
- 16. Android getPackageInfo without getPackageManager
- 17. android coverflow without gallery
- 18. Braintree on Android without gms/wallet
- 19. android linkify intent
- 20. nullpointer on intent android
- 21. Android Intent-filter VerifyError
- 22. Android ViewPageIndication with intent
- 23. Android Flavor related Intent
- 24. android intent putExtras
- 25. android listview and intent
- 26. Android ViewFlipper With Intent
- 27. ACTION_SEND intent android
- 28. android listview intent
- 29. Android intent image
- 30. phonegap android 2.2 call javascript
对于任何遇到同样问题的人,我都做了 - 还有一个地方需要重新命名 - 在LibraryProject中,转到src/com/google/zxing/client/android/Intents.java寻找“public static final String ACTION“并将其更改为新的intent名称。 – Matt