Question by
mojtabashamsabadi · Oct 07, 2019 at 04:34 PM ·
#pragma#pragma strict
not run app again when read nfc tag
------------------------------------------------------------------- Manifest File -------------------------------------------------------------
<activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name" android:screenOrientation="portrait" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:hardwareAccelerated="false">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<action android:name="android.nfc.action.TECH_DISCOVERED"/>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED" android:value="true" android:resource="@xml/nfc_tech_filter"/>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
<meta-data android:name="unity.build-id" android:value="dd24cbfb-4841-44c5-bd24-7e233c3ae163" />
<meta-data android:name="unity.splash-mode" android:value="0" />
<meta-data android:name="unity.splash-enable" android:value="True" />
----------------------------------------------------------- Code ------------------------------------------------------------------------------
mActivity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic<AndroidJavaObject>("currentActivity"); // Activities open apps
mIntent = mActivity.Call<AndroidJavaObject>("getIntent");
sAction = mIntent.Call<String>("getAction"); // resulte are returned in the Intent object
if (sAction == "android.nfc.action.TECH_DISCOVERED")
{
// Debug.Log("TAG DISCOVERED");
// Get ID of tag
AndroidJavaObject mNdefMessage = mIntent.Call<AndroidJavaObject>("getParcelableExtra", "android.nfc.extra.TAG");
if (mNdefMessage != null)
{
byte[] payLoad = mNdefMessage.Call<byte[]>("getId");
string text = ByteToString(payLoad);
//tag_output_text.text += "This is your tag text: " + text;
//Destroy(GetComponent("MeshRenderer")); //Destroy Box when NFC ID is displayed
//tagID = text;
tag_output_text.text = text;
}
else
{
tag_output_text.text = "Not Found";
}
//tagFound = true;
// How to read multiple tags maybe with this line
//mIntent.Call("removeExtra", "android.nfc.extra.TAG");
return;
}
Comment
Your answer
Follow this Question
Related Questions
Enter full screen on Computer without a new scene 1 Answer
Log In code, if done correctly, Load another scene. 0 Answers
Working Computer UI. 0 Answers
How To Show a Question UI Canvas After Collider ? 1 Answer
Help, Losing lives too easily 1 Answer