Back to project page notify.
The source code is released under:
GNU General Public License
If you think the Android project notify listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.example.notify; /*from w w w . j a v a2s . c o m*/ import android.content.ActivityNotFoundException; import android.content.Intent; import android.os.Message; import android.os.Messenger; import android.os.RemoteException; import org.apache.http.conn.util.InetAddressUtils; import java.net.InetAddress; import java.net.NetworkInterface; import java.util.Collections; import java.util.List; public class OurUtils { /* Credit to Whome on stackoverflow */ public static String getIP() { try { List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); for (NetworkInterface intf : interfaces) { List<InetAddress> addrs = Collections.list(intf.getInetAddresses()); for (InetAddress addr : addrs) { if (!addr.isLoopbackAddress()) { String addr1 = addr.getHostAddress().toUpperCase().replaceAll("^/", ""); if (InetAddressUtils.isIPv4Address(addr1)) { return addr1; } } } } } catch (Exception ex) { ex.printStackTrace(); } return null; } public static void sendMessageToActivity(EnumMessage code) { OurUtils.sendMessageToActivity(code, ""); } public static void sendMessageToActivity(EnumMessage code, String args) { if (MainActivity.mh != null ) { try { new Messenger(MainActivity.mh).send(Message.obtain(null, 0, new Object[] { code, args })); } catch (RemoteException e) { e.printStackTrace(); } } } public static Boolean scanQr() { try { Intent intent = new Intent("com.google.zxing.client.android.SCAN"); intent.putExtra("SCAN_MODE", "QR_CODE_MODE"); MainActivity.ma.startActivityForResult(intent, 1); return true; } catch (ActivityNotFoundException e) { return false; } } }