|
بۇ يازمىنى ئاخىرىدا 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 كودى
-
- package="com.connect"
- android:versionCode="1"
- android:versionName="1.0" >
-
-
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
-
- android:label="@string/app_name"
- android:name=".Connect" >
-
-
-
-
-
-
-
-
مەزمۇننى كۆچۈرۈۋېلىش
بۇ كود تىكى مۇھىم يېرى ئاۋۇ ئاستىدىكى ھوقۇقى :
ئاخىردا
كورۈنمە يۈزى كودى
main.xml كودى
-
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
-
- android:layout_width="fill_parent"
- 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"/>/
مەزمۇننى كۆچۈرۈۋېلىش
چۈشەنمىگەن يەرلەر بولسا ئىنكاس يازساڭلار بولىدۇ
كودنىڭ ھەممىسىنى يوللاپ قويدۇم تۇلۇق كودنى يوللاپ قويمىساممۇ بولار
ئەڭ ياخشىسى يوللاپ قوياي
Connect.zip
(56.48 KB, چۈشۈرۈش سانى: 20)
|
باھالاش
-
باھا خاتىرىسى
|