2
votes

Can anyone explain to me the following code?

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

In the zxing barcode scanner code in Intents.java (like the above). The intent will call which activity and so on?

Thanks in Advance

1

1 Answers

2
votes

You are raising an intent for that specific action (com.google.zxing.client.android.SCAN).

The barcode scanner application by zxing registers an activity with that action as an intent filter, so Android knows how to resolve intents for that action and links them to that activity.

When you execute that intent, it will open that specific Activity in the zxing application. When this activity finishes it will return control to your Activity with the result. You need to handle this in the onActivityResult callback.