Мобил иловалар яратиш лектор: Аюпов Равшан Хамдамович Кириш Модулнинг мақсади ва вазифалари



Download 8,33 Mb.
bet46/77
Sana20.07.2022
Hajmi8,33 Mb.
#828560
1   ...   42   43   44   45   46   47   48   49   ...   77
Bog'liq
Mobil ilovalar dasturiy taminoti

MainAcivity.java файли мос ҳолда ўзгартирилади

  • activity_main.xml файли ҳам мос ҳолда ўзгартирилади


    "1.0" encoding="utf-8"?>
    xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" >

    android:layout_height="wrap_content" />

    MainActivity.java

    //Package name here import android.app.Activity; import android.os.Bundle; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection;
    import android.util.Log; public class MainActivity extends Activity { /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
    } public void checkInternetConnection(){
    ConnectivityManager check = (ConnectivityManager) this.context. getSystemService(Context.CONNECTIVITY_SERVICE); if (check != null)
    {
    NetworkInfo[] info = check.getAllNetworkInfo(); if (info != null)
    for (int i = 0; i
    if (info[i].getState() == NetworkInfo.State.CONNECTED)
    {
    Toast.makeText(context, "Internet is connected",
    Toast.LENGTH_SHORT).show();
    } } else{
    Toast.makeText(context, "not conencted to internet",
    Toast.LENGTH_SHORT).show();
    }
    }

    }
    Binary маълумотларни юклаб олиш20

    1. Янги DownloadData номли Андроид лойиҳа яратамиз

    2. Лойиҳанинг main.xml файлини қуйидагича ўзгартирамиз


      xmlns:android=”http://schemas.android.com/apk/res/android”
      android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:orientation=”vertical” >
      android:id=”@+id/img” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_gravity=”center” />


    3. AndroidManifest.xml файлига қуйидаги permission қўшиб қўйилади



    1. MainActivity.java


    // Package номи лойиҳангизга мос қолдиринг
    // Керакли синфларни import қилинг public class MainActivity extends Activity {
    ImageView img;
    private InputStream OpenHttpConnection(String urlString) throws IOException{
    InputStream in = null; int response = -1;
    URL url = new URL(urlString);
    URLConnection conn = url.openConnection(); if (!(conn instanceof HttpURLConnection)) throw new IOException(“Not an HTTP connection”); try{
    HttpURLConnection httpConn = (HttpURLConnection) conn; httpConn.setAllowUserInteraction(false); httpConn.setInstanceFollowRedirects(true); httpConn.setRequestMethod(“GET”); httpConn.connect();





    Download 8,33 Mb.

    Do'stlaringiz bilan baham:
  • 1   ...   42   43   44   45   46   47   48   49   ...   77




    Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
    ma'muriyatiga murojaat qiling

    kiriting | ro'yxatdan o'tish
        Bosh sahifa
    юртда тантана
    Боғда битган
    Бугун юртда
    Эшитганлар жилманглар
    Эшитмадим деманглар
    битган бодомлар
    Yangiariq tumani
    qitish marakazi
    Raqamli texnologiyalar
    ilishida muhokamadan
    tasdiqqa tavsiya
    tavsiya etilgan
    iqtisodiyot kafedrasi
    steiermarkischen landesregierung
    asarlaringizni yuboring
    o'zingizning asarlaringizni
    Iltimos faqat
    faqat o'zingizning
    steierm rkischen
    landesregierung fachabteilung
    rkischen landesregierung
    hamshira loyihasi
    loyihasi mavsum
    faolyatining oqibatlari
    asosiy adabiyotlar
    fakulteti ahborot
    ahborot havfsizligi
    havfsizligi kafedrasi
    fanidan bo’yicha
    fakulteti iqtisodiyot
    boshqaruv fakulteti
    chiqarishda boshqaruv
    ishlab chiqarishda
    iqtisodiyot fakultet
    multiservis tarmoqlari
    fanidan asosiy
    Uzbek fanidan
    mavzulari potok
    asosidagi multiservis
    'aliyyil a'ziym
    billahil 'aliyyil
    illaa billahil
    quvvata illaa
    falah' deganida
    Kompyuter savodxonligi
    bo’yicha mustaqil
    'alal falah'
    Hayya 'alal
    'alas soloh
    Hayya 'alas
    mavsum boyicha


    yuklab olish