How can i solve the this problem? I don't see System.out.println I want to see System.out.println ethe of in. I see error in logcat. My codes are in the external java class.
My codes are here:
package com.example.test;
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
public class bilgiCek extends AppCompatActivity {
public static void telefonBilgi(){
TelephonyManager bilgiler = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); // Error is here.
String simUlke = bilgiler.getSimCountryIso();
String netUlke = bilgiler.getNetworkCountryIso();
String imei = bilgiler.getImei();
String simNo = bilgiler.getSimSerialNumber();
String sesMail = bilgiler.getVoiceMailNumber();
System.out.println("İmei Numarası" + imei);
}
}
Error outpu are here:
> Task :app:compileDebugJavaWithJavac FAILED
C:\Users\90505\AndroidStudioProjects\test\app\src\main\java\com\example\test\smsOkuma.java:16: error: non-static method getSystemService(String) cannot be referenced from a static context
TelephonyManager bilgiler = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
^
1 error
FAILURE: Build failed with an exception