Use NFC to get Android programs running automatically

Source: Internet
Author: User

This article is using the NFC label paper and the Millet 3 handset test

Create a new activity class first

[Java]  View Plain  copy   package com.cayden.run.application;      import  android.app.activity;   import android.app.pendingintent;   import  android.content.intent;   import android.nfc.ndefmessage;   import  android.nfc.ndefrecord;   import android.nfc.nfcadapter;   import android.nfc.Tag;    import android.nfc.tech.ndef;   import android.os.bundle;   Import  android.view.View;   import android.widget.button;   import  android.widget.toast;  /**   *    *     *  @author  cuiran   *  @version  1.0.0   */   public class  runapplicationactivity extends activity {           private button mselectautorunapplication;       private String mPackageName;        private nfcadapter mnfcadapter;       private PendingIntent  mpendingintent;           @Override         Protected void oncreate (bundle savedinstancestate)  {            // TODO Auto-generated method stub            super.oncreate (savedinstancestate);            setcontentview (r.layout.activity_auto_run_application);               mSelectAutoRunApplication =  (Button)  findviewbyid ( r.id.button_select_auto_run_application);               mnfcadapter =&nBsp Nfcadapter.getdefaultadapter (this);           mpendingintent  = pendingintent.getactivity (this, 0, new intent, this,                    getclass ()),  0);           }          public void  onnewintent (intent intent)  {           if   (mpackagename == null)                 return;              Tag  Detectedtag = intent.getparcelableextra (Nfcadapter.extra_tag);               writenfctag (Detectedtag);       }           public void onresume ()  {  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.