小编rav*_*vi 的帖子

tm.getDeviceId()已弃用?

我正在获取IMEI和设备ID,所以我在这里得到一个问题getDeviceId()已被弃用.

TelephonyManager tm = (TelephonyManager) 
                 getSystemService(this.TELEPHONY_SERVICE);

imei = tm.getDeviceId();
device = Settings.Secure.getString(this.getContentResolver(),
           Settings.Secure.ANDROID_ID);
Run Code Online (Sandbox Code Playgroud)

java android telephonymanager android-8.0-oreo

15
推荐指数
3
解决办法
2万
查看次数

使用警报或自定义消息接收非JSON数据/空数据时处理活动

我按照这个来读取android中的JSON数据

我在那里将结果数据传递给另一个活动

public class MainAct1 extends Activity {

private static String urlString;

private static final String My_TAG= "Log Status";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.data);

    if(Dcon.isInternetAvailable(this))
    {
        try {
            urlString = "https://example.net/api_json";
            new ProcessJSON(this).execute();
        }

        catch (Exception e) {
            AlertDialog.Builder builder = new AlertDialog.Builder(MainAct1.this);
            builder.setMessage("Note: Your Server ID is Invalid \n Please check the Server Status");
            builder.setTitle("Please Check Server Details");
            builder.setPositiveButton("OK",null);

            builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss(); …
Run Code Online (Sandbox Code Playgroud)

android json

7
推荐指数
1
解决办法
235
查看次数

标签 统计

android ×2

android-8.0-oreo ×1

java ×1

json ×1

telephonymanager ×1