我的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