android-internet

Checking Internet connection in Android

匆匆过客 提交于 2019-11-28 14:26:16
Is there any background task which runs with in application to check for internet connectivity for below scenarios as common ? 1.Start of parsing/fetching data from server 2.In between of parsing/fetching from server Any sample code or links helps me a lot. You can start an IntentService or Service and use this: public boolean CheckInternet() { ConnectivityManager connec = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); android.net.NetworkInfo wifi = connec.getNetworkInfo(ConnectivityManager.TYPE_WIFI); android.net.NetworkInfo mobile = connec.getNetworkInfo

android how to get indicate when the internet connection is lost?

久未见 提交于 2019-11-28 08:23:53
I'm developing an android application and I want to get a notification when the internet (wifi or packet data connection) connection is lost. On my approach I can get the status of the connection as: private boolean isNetworkAvailable() { ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null && activeNetworkInfo.isConnected(); } while having this in the Manifest: <uses-permission android:name="android.permission.ACCESS_NETWORK

Android Localhost?

此生再无相见时 提交于 2019-11-28 06:13:34
问题 I know this has been asked and answered before, but I use 10.0.2.2 for the emulator. And I heard I must use something else for my real device. Can someone tell me what that is? And can I have them both run off of 1 URL. Instead of having one for the emulator and actual device. 回答1: Android Localhost? localhost of an Android device is localhost , 127.0.0.1. I use 10.0.2.2 for the emulator That refers to localhost of the computer running the emulator. And I heard I must use something else for

Why does ping works on some devices and not others?

蹲街弑〆低调 提交于 2019-11-27 23:09:55
I have the following code in my app... Runtime runtime = Runtime.getRuntime(); Process process = runtime.exec("/system/bin/ping -c 1 8.8.8.8"); return process.waitFor(); ... and I'm seeing that it works (returns 0) on some devices (e.g. Motorola G) but doesn't work (returns 2) on other devices (e.g. Galaxy S3). I've checked the Galaxy S3 device and it definitely has a "/system/bin/ping" file and of course I've made sure that it is indeed connected to the internet. Anyone have any ideas why the command might not work on some devices... and what I can do to get it to work? JTY The way ping is

Android - Programmatically check internet connection and display dialog if notConnected

醉酒当歌 提交于 2019-11-27 14:30:49
问题 I am working on a live project. and when user click on the app. the welcome screen appears(there is a webview on that screen). and if the internet is not connected then the app crashes. Basically, my problem is to check programmatically that is mobile is connected to internet or not. if not then don't fetch the data from webservice into webview and display a dialog box showing "Check your internet connection" while doing research i found many things, and i have tried to implement that. but,

Download Images From URL to SD Card

情到浓时终转凉″ 提交于 2019-11-27 13:21:12
问题 I am trying to create a very simple Image Downloading app. in which i want to download all images from this url to sd card: https://www.dropbox.com/sh/5be3kgehyg8uzh2/AAA-jYcy_21nLBwnZQ3TBFAea this code works to load image in imageview: package com.example.imagedownloadsample; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.widget.ImageView; import com.squareup.picasso.Picasso; public class MainActivity extends ActionBarActivity { @Override protected

@font-face declarations don't work in Android 4.3 Internet browser?

最后都变了- 提交于 2019-11-27 10:36:57
问题 My Samsung Galaxy S3 phone recently upgraded from Android 4.1.3 to Android 4.3. Now several websites I designed which I tested in the Android internet browser are not displaying fonts I have declared with @font-face . What do I need to do to fix this? One of the sites (development version): http://beta.kdfansite.com Here is some of the related CSS for Open Sans: @font-face { font-family: 'OpenSansSemibold'; src: url('http://beta.kdfansite.com/wp-content/themes/scrollider/scrollider/webfonts

Android internet connectivity check problem

為{幸葍}努か 提交于 2019-11-26 22:51:07
I'm new to Android development and working on an Android application that requires the phone to be connected to the internet, through either Wifi, EDGE or 3G. This is the code that I'm using to check whether an internet connection is available public static boolean isConnected() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); return cm.getActiveNetworkInfo().isConnectedOrConnecting(); } I've also set these permissions in the manifest file <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android

Why does ping works on some devices and not others?

守給你的承諾、 提交于 2019-11-26 21:20:50
问题 I have the following code in my app... Runtime runtime = Runtime.getRuntime(); Process process = runtime.exec("/system/bin/ping -c 1 8.8.8.8"); return process.waitFor(); ... and I'm seeing that it works (returns 0) on some devices (e.g. Motorola G) but doesn't work (returns 2) on other devices (e.g. Galaxy S3). I've checked the Galaxy S3 device and it definitely has a "/system/bin/ping" file and of course I've made sure that it is indeed connected to the internet. Anyone have any ideas why

Android internet connectivity check problem

倾然丶 夕夏残阳落幕 提交于 2019-11-26 08:29:16
问题 I\'m new to Android development and working on an Android application that requires the phone to be connected to the internet, through either Wifi, EDGE or 3G. This is the code that I\'m using to check whether an internet connection is available public static boolean isConnected() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); return cm.getActiveNetworkInfo().isConnectedOrConnecting(); } I\'ve also set these permissions in the manifest file