获取Netflix ESN


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

/**
 * 获取Netflix ESN方法:
 * 发送广播给Netflix,Netflix回发广播
 */
public class MainActivity extends AppCompatActivity {

    private BroadcastReceiver receiver;
    private TextView tv_esn;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Toast.makeText(this, String.valueOf(hasNetflix()), Toast.LENGTH_SHORT).show();
        tv_esn = findViewById(R.id.tv_esn);
        receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                String esn = intent.getStringExtra("ESNValue");
                tv_esn.setText(esn);
            }
        };
        IntentFilter filter = new IntentFilter("com.netflix.ninja.intent.action.ESN_RESPONSE");
        registerReceiver(receiver, filter, "com.netflix.ninja.permission.ESN", null);

        Intent esnQueryIntent = new Intent("com.netflix.ninja.intent.action.ESN");
        esnQueryIntent.setPackage("com.netflix.ninja");
        esnQueryIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
        sendBroadcast(esnQueryIntent);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (receiver != null) {
            unregisterReceiver(receiver);
        }
    }

    public boolean hasNetflix(){
        String product  = Build.PRODUCT;
        if (product.contains("WON")){
            return false;
        }else {
            return true;
        }
    }
}



    
    

    
        
            
                

                
            
        
    


注意:需要在系统编译环境下,进行签名才可以(mm)

你可能感兴趣的:(Android)