Set a button, when clicked, to check whether the network connection is not connected with a determined will pop up a message box, ask the god to the next code
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
button_onClick () {
if (! check_connect_net (context)) {
Builder builder = new AlertDialog.Builder (a);
builder.setTitle ("").. setMessage (msg) setPositiveButton ("no network OK", null!) show ();.
builder = null;
}
}
public static boolean check_connect_net (Context con) {
ConnectivityManager cwjManager = (ConnectivityManager) con
. GetSystemService (Context.CONNECTIVITY_SERVICE);
try {
if (cwjManager.getActiveNetworkInfo ()! = null
&& CwjManager.getActiveNetworkInfo (). IsAvailable ()) {
return true;
}
} Catch (Exception e) {
e.printStackTrace ();
}
return false;
}
Reply:
Great God so bad ah?
dongtai.setOnClickListener (new OnClickListener () {
public void onClick (View v) {
if (getpwdButtonState == 0) {
return;
}
AppContext.msisdn = phonenumber.getText () toString ();.
/ / Get the interface to send to the server, the server responds to pop up a dialog box
if (phonenumber.getText (). toString (). length ()! = 11) {
text.setText ("Please enter the phone number");
text.setTextColor (0xffda0000);
text.setTextSize (15);
} Else {
/ / Dongtai.setBackgroundResource (R.drawable.bt_getpwd_pressed);
/ / Dongtai.setText ("Get dynamic password");
getpwdButtonState = 0;
dialog = WaitingDialog.showDialog (Login.this,
"Dynamic password access, please wait ...");
new Thread () {
@ Override
public void run () {
try {
ssss = httppost.getDongTai (sd, phonenumber
.. GetText () toString ());
Message message = new Message ();
message.what = 126;
message.obj = ssss;
mHandler.sendMessage (message);
} Catch (Exception e) {
mHandler.sendEmptyMessage (0);
e.printStackTrace ();
}
}
.} Start ();
}
}
});
This is my button is used to obtain the dynamic password, under no circumstances want to click on the network without the network after the pop-up boxes, to bring the OK button. . . Please help change it ah
Reply:
protected void button () {
super.onStart ();
/ / Get the network connection service
ConnectivityManager manager = (ConnectivityManager) this.getSystemService
(Context.CONNECTIVITY_SERVICE);
/ / Get the information
all network connectionsNetworkInfo info = manager.getActiveNetworkInfo ();
if (info! = null && info.isConnected ()) {
Toast.makeText (this, "the network connection is successful!!!", Toast.LENGTH_LONG) show ();.
} Else {
AlertDialog.Builder builder = new AlertDialog.Builder (this);
builder.setTitle ("open network connections");
builder.setMessage ("the network is not connected, please check the network settings set");
builder.setPositiveButton ("OK", new OnClickListener () {
@ Override
public void onClick (DialogInterface dialog, int which) {
if (android.os.Build.VERSION.SDK_INT> 10) {
/ / Open WIFI settings interface
startActivity (new Intent (android.provider.Settings.ACTION_WIFI_SETTINGS));
}
dialog.cancel ();
}
});
builder.setNegativeButton ("Cancel", new OnClickListener () {
@ Override
public void onClick (DialogInterface dialog, int which) {
dialog.cancel ();
}
});
builder.show ();
}
}
This is not what you want
Reply:
My code 2L, which add about this great God help function ah. . .
Reply:
My code in 3L, which add about this great God help function ah. . .
Reply:
button_onClick () {
if (! check_connect_net (context)) {
Builder builder = new AlertDialog.Builder (a);
builder.setTitle ("").. setMessage (msg) setPositiveButton ("no network OK", null!) show ();.
builder = null;
}
}
public static boolean check_connect_net (Context con) {
ConnectivityManager cwjManager = (ConnectivityManager) con
. GetSystemService (Context.CONNECTIVITY_SERVICE);
try {
if (cwjManager.getActiveNetworkInfo ()! = null
&& CwjManager.getActiveNetworkInfo (). IsAvailable ()) {
return true;
}
} Catch (Exception e) {
e.printStackTrace ();
}
return false;
}
Reply:
Nobody what, to help look ah. . . 3L code how to change ah
Reply:
FileOutputStream fos = new FileOutputStream (file1);
byte [] b = new byte [2048];
int j = 0;
int ll = 0;
while ((j = input.read (b))! = -1) {
fos.write (b, 0, j);
ll + = j;
/ / (Ll / length) * 100
/ / PublishProgress ((int) ((ll / length) * 100));
publishProgress ((int) ((ll / (float) length) * 100));
/ / Thread.sleep (500);
}
fos.flush ();
fos.close ();
After then call
@ Override
protected void onProgressUpdate (Integer. .. values) {
/ / String vlaue = values [0] toString ();.
/ / MDialog.setMessage ("Downloading" + values [0] + "%");
/ / MDialog.show ();
/ / MDialog.setProgress (Integer.parseInt (vlaue));
if (mDialog! = null) {
mDialog.setMessage ("Downloading" + values [0] + "%");
}
super.onProgressUpdate (values);
}
No comments:
Post a Comment