package com.jiit.minorproject.emergencycontact;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import java.util.prefs.Preferences;
公共类MainActivity扩展了Activity {
/*
* HOSPITAL, POLICE, FIRESTATION, and AMBULANCE are constant variables that are assigned
* to their respective emergency itent. It helps us to draw icons and perform web services
* related activities.
*/
private static final int HOSPITAL = 1;
private static final int POLICE = 2;
private static final int FIRESTATION = 3;
private static final int AMBULANCE = 4;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(Preferences.readString(this, Preferences.NAME) == null){
startActivity(new Intent(this, Registration.class));
if(Preferences.readString(this, Preferences.NAME) == null){
this.finish();
}
} else {
setContentView(R.layout.activity_main);
}
}
无法解析Prefernces.readString方法
答案 0 :(得分:1)
java.util.prefs.Preferences通常不会在Android代码中使用。但即使它是 - 该类中没有readString方法。查看其上的文档https://docs.oracle.com/javase/7/docs/api/java/util/prefs/Preferences.html
我不确定为什么你认为这个功能应该存在,但它确实没有。
答案 1 :(得分:0)
如何创建活动PREFERENCE Android?
首先创建一个新的XML
然后这个xml说出MainActivity的女儿是怎样的
你看起来像这样
它是第一个然后玩jeje,reed官方信息。