I want to compare IMEI number in my phone with the data I declare, but the bug says: 'Operator == can not be applied to 'java.lang.String', 'long' How do I fix that?
MainActivity.java
public class MainActivity extends AppCompatActivity {
    TelephonyManager manager;
    private Button button;
    TextView textView;
    String IMEI;
    long IMEI2 = 356261058647361;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        button = (Button)findViewById(R.id.next);
        textView = (TextView)findViewById(R.id.textview1);
        manager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
        IMEI = manager.getDeviceId();
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View arg0) {
                if(IMEI == IMEI2){
                    textView.setText("IMEI NUMBER : " + IMEI);
                }else{
                    textView.setText("data IMEI and IMEI2 did not match");
                }
            }
        });
    }
}
                if(IMEI.equals(String.valueOf(IMEI2)){
    textView.setText("IMEI NUMBER : " + IMEI);
}else{
    textView.setText("data IMEI and IMEI2 did not match");
}
                        Try this
 button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View arg0) {
                if(IMEI2.equals(""+IMEI){
                    textView.setText("IMEI NUMBER : " + IMEI);
                }else{
                    textView.setText("data IMEI and IMEI2 did not match");
                }
            }
        });
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With