How to export an activity so other apps can call it?

前端 未结 2 907
时光取名叫无心
时光取名叫无心 2020-12-07 00:47

Well I searched a lot, but I didn\'t find a precise answer how to export an Activity, so an app can start it with startActivityforResult.

How do I achie

2条回答
  •  无人及你
    2020-12-07 01:34

    You need to declare an intent-filter in your Manifest (I took the following example from Barcode Scanner) :

    
        
            
            
        
    
    

    Then create an intent with the same action string :

    Intent intent = new Intent("com.google.zxing.client.android.SCAN");
    startActivityForResult(intent, code);
    

    Android should start your activity (or it will show a drop-down box if there are multiple apps sharing the same action string).

提交回复
热议问题