After you navigate to the GPS settings dialog on the following source, check 
the GPS usage and click the Back button

Intent = new Intent (this, CurrentLocatinActivity.class);

StartActivity (intent);

I want to reintroduce this part of the intent. Where should I do it?
Or if I need to create a new method, how do I create one?



public class MainActivity extends AppCompatActivity {

    String gpsEnabled;

    Intent intent;

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

        chkGpsService();
    }

    private boolean chkGpsService() {

        //GPS가 켜져 있는지 확인함.
        gpsEnabled = 
android.provider.Settings.Secure.getString(getContentResolver(), 
Settings.Secure.LOCATION_PROVIDERS_ALLOWED);

        if (!(gpsEnabled.matches(".*gps.*") && 
gpsEnabled.matches(".*network.*"))) {
            //gps가 사용가능한 상태가 아니면
            new AlertDialog.Builder(this).setTitle("GPS 설정").setMessage("GPS가 
꺼져 있습니다. \nGPS를 활성화 하시겠습니까?").setPositiveButton("GPS 켜기", new 
DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int which) 
{
                    //GPS 설정 화면을 띄움
                    Intent intent = new 
Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                    startActivity(intent);
                }
            }).setNegativeButton("닫기", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {

                }
            }).create().show();

        }else if((gpsEnabled.matches(".*gps.*") && 
gpsEnabled.matches(".*network.*"))) {
            Toast.makeText(getApplicationContext(), "정보를 읽어오는 중입니다.", 
Toast.LENGTH_LONG).show();
            intent = new Intent(this, CurrentLocatinActivity.class); //현재 위치 화면 
띄우기 위해 인텐트 실행.
            startActivity(intent);
        }
        return false;
    }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/f4b0c4fb-e94d-4c3f-9a2e-0d061c314ba7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to