I want to simulate the touch event for my application. My manifest is like
<activity
android:name=".activity.TagActivity_"
android:label="@string/app_name"
android:launchMode="singleTask"
android:noHistory="true"
android:permission="android.permission.NFC"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED" />
</intent-filter>
<meta-data
android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="@xml/nfc_tech_filter" />
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="ext"
android:pathPrefix="/abc:d"
android:scheme="vnd.android.nfc" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
Question (1): I want to invoke my application from other application. How do I do that? My current code is like:
try {
final Intent intent = new Intent(NfcAdapter.ACTION_NDEF_DISCOVERED);
NdefMessage ndefMessage = buildNdefMessage(getTagData());
intent.putExtra(NfcAdapter.EXTRA_NDEF_MESSAGES, new NdefMessage[] {ndefMessage});
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
But this is not invoking my application. probably because the data type and path prefix do not match. How do I pass this while starting the activity?
Question (2): For temp purpose I have added
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
to make it work, and my application is invoked. But while reading the tag I check the tag type, and since I am not passing any tag type, my app crashes. So how do I create a tag instance? There is no constructor for this. I mean I can't do Ndef ndef = new Ndef();
. And I don't basically have a tag so I can't event do Ndef ndef = Ndef.get(tag);
.