Android Open Source - notify Our Utils






From Project

Back to project page notify.

License

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.

Java Source Code

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;
        }
    }
}




Java Source Code List

com.example.notify.AccessibilityListenerService.java
com.example.notify.BackgroundService.java
com.example.notify.Broadcast.java
com.example.notify.DisplayFragments.java
com.example.notify.EnumMessage.java
com.example.notify.FragmentAccessibility.java
com.example.notify.FragmentBroadcastReconnect.java
com.example.notify.FragmentConnect.java
com.example.notify.FragmentConnected.java
com.example.notify.FragmentConnecting.java
com.example.notify.FragmentManual.java
com.example.notify.FragmentNoQrcodeScanner.java
com.example.notify.FragmentQrcodeWrong.java
com.example.notify.FragmentReconnect.java
com.example.notify.FragmentWifiWarning.java
com.example.notify.IntentBroadcastReceiver.java
com.example.notify.MainActivity.java
com.example.notify.OurUtils.java