Wednesday, 23 September 2015

how to create dialog box and jump into mobile setting or wifi/gps

package com.dialog;

import android.os.Bundle;
import android.provider.Settings;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.view.Menu;
import android.view.View;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
   
        public void dialog(View v)
        {
        Builder aa=new AlertDialog.Builder(MainActivity.this);
        aa.setTitle("internet not working");
        aa.setMessage("press ok to open internet setting else press no");
        aa.setPositiveButton("hlo",new OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Intent aa=new Intent (Settings.ACTION_SETTINGS);
startActivity(aa);
}
});
       
        Dialog ab=aa.create();
        ab.show();
}

   

 
}

No comments:

Post a Comment

Earn money online through app sign up

Hey, I just transferred some money to a friend using Chillr. Its super quick and easy. Check it out. https://m.chillr.in/invite Hey! I...