يانفۇننىڭ تورغا ئۇلانغان ئۇلانمىغانلىقىنى تەكشۈرۈش(java كودى)
بۇ يازمىنى ئاخىرىدا boptula تەھرىرلىگەن. ۋاقتى2014-11-28 22:22ئەسسالامۇ ئەليكۇم !
جاۋاكودى
connect.Java كودى
package com.connect;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class Connect extends Activity {
Button ok;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ok = (Button)findViewById(R.id.ok);
ok.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
NetWorkStatus();
}
});
}
private boolean NetWorkStatus() {
ConnectivityManager cwjManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
cwjManager.getActiveNetworkInfo();
boolean netSataus = true;
if (cwjManager.getActiveNetworkInfo() != null) {
netSataus = cwjManager.getActiveNetworkInfo().isAvailable();
Toast.makeText(this, "yanfun torgha ulinip boptu", Toast.LENGTH_LONG).show();
}else
{
Builder b = new AlertDialog.Builder(this).setTitle("yanfun torgha ulanmighan")
.setMessage("yanfun torgha ulan maptu ,torgha ulamsiz ?");
b.setPositiveButton("ulaymen", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton) {
Intent mIntent = new Intent("/");
ComponentName comp = new ComponentName(
"com.android.settings",
"com.android.settings.WirelessSettings");
mIntent.setComponent(comp);
mIntent.setAction("android.intent.action.VIEW");
startActivityForResult(mIntent,0);
}
}).setNeutralButton("yak", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel();
}
}).show();
}
return netSataus;
}
}
ئاۋال كونۇپكىنى بىر قىممەتكە تەڭ قىلىۋېلىپ ئاندىن كونۇپكىنىڭ چىكىلىش ھادىسىسىگەبۇ كودنى يازىمىز ئاندىن
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
NetWorkStatus();
}
ئاندىن ئۇ كود نىڭ ئاستىغا بۇنى
private boolean NetWorkStatus() {
ConnectivityManager cwjManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
cwjManager.getActiveNetworkInfo();
boolean netSataus = true;
if (cwjManager.getActiveNetworkInfo() != null) {
netSataus = cwjManager.getActiveNetworkInfo().isAvailable();
Toast.makeText(this, "yanfun torgha ulinip boptu", Toast.LENGTH_LONG).show();
}else
{
Builder b = new AlertDialog.Builder(this).setTitle("yanfun torgha ulanmighan")
.setMessage("yanfun torgha ulan maptu ,torgha ulamsiz ?");
b.setPositiveButton("ulaymen", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton) {
Intent mIntent = new Intent("/");
ComponentName comp = new ComponentName(
"com.android.settings",
"com.android.settings.WirelessSettings");
mIntent.setComponent(comp);
mIntent.setAction("android.intent.action.VIEW");
startActivityForResult(mIntent,0);
}
}).setNeutralButton("yak", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel();
}
}).show();
}
return netSataus;
}
AndroidMainfest.xml كودى
android:versionCode="1"
android:versionName="1.0" >
android:label="@string/app_name" >
android:name=".Connect" >
بۇ كود تىكى مۇھىم يېرى ئاۋۇ ئاستىدىكى ھوقۇقى :
ئاخىردا
كورۈنمە يۈزى كودى
main.xml كودى
android:layout_height="fill_parent"
android:orientation="vertical" >
android:layout_height="wrap_content"
android:text="@string/hello" />
android:id="@+id/ok"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="sinash"/>/
چۈشەنمىگەن يەرلەر بولسائىنكاس يازساڭلار بولىدۇ
كودنىڭ ھەممىسىنى يوللاپ قويدۇم تۇلۇقكودنىيوللاپ قويمىساممۇ بولار
ئەڭياخشىسى يوللاپ قوياي
چۈشنەلمىدىم مەن
مۇشۇ كوددىگەننى ئىشلىتىشنى پەقەت بىلمەيمەن جۇمۇ مۇشۇ تېمىدا يېزىلغان لارنى ئازراق چۈشەن گەن بولسام ئۆلەي manmu pakat quxanmidim چۈشەنمىگۇدەك نەرى بار سىزمۇ چۈشنىشكە تىرشىپ تەھلىل قىلىپ باخساڭلار سىللىمۇ چۈشنىپ كىتىسىلەر، ياخشى ئاندىروئىد كودلىرى چىقىۋاتىدۇ مانا ...ھەقلىق تېما قوبۇل قىلىش پائالىيىتىنىڭ ئۈنۈمى كۆرۈلۈشكە باشلىدى . بولسا توختىتىپ قويماي بىرلىكتە ئالپنىڭ تەرەققىياتىنى دېتال ۋە توربەت يېزىش يۈنىلىشىگە ماسلاشتۇرايلى .موشۇ تۈردە كۆپرەك ئىقتىدارلىق ئادەملىرىمىزنىڭ يېتىشىپ چىقىشىنى ئۆمىد قىلىمەن . نىمانداق دەيسىلە قىرىنداشلا باشقىلا بۇنى ياخشى كۆڭلى بىلەن يوللىسا شۇنداق دىسەڭلا بولامدۇ سىلە چۈشەنمىسەڭلا چۈشۈندىغانلا پايدىلانسۇنراسنى ئىيىتسام مەنمۇ چۈشەنمەيمەن
تىما ئىگىسى رەھمەت سىزگە تىخىمۇ تىرشىڭ مەنمۇ چۈشەنمەيمە لىكىن قىزىقىۋاتىمە رەھمەت
بەت:
[1]