dkrivoruchko / ScreenStream

ScreenStream Android App
https://screenstream.io
MIT License
1.7k stars 337 forks source link

Share screen via hotspot. #111

Closed ghost closed 4 years ago

ghost commented 4 years ago

I am using java version https://github.com/dkrivoruchko/ScreenStream/tree/1.x .

Java version only share screen via wifi .

How can I share the screen via hotspot ?

I tried with this code to get hotspot IP.

    public static String getWifiIp(@NonNull Context context) {
    WifiManager wifimanager = (WifiManager) context.getApplicationContext().getSystemService
            (Context.WIFI_SERVICE);
    if (wifimanager == null) {
        return null;
    }
    WifiInfo wifiInfo = wifimanager.getConnectionInfo();
    if (wifiInfo != null) {
        return intToIp(wifiInfo.getIpAddress());
    }
    return null;
    }

    private static String intToIp(int i) {
    return (i & 0xFF) + "." + ((i >> 8) & 0xFF) + "." + ((i >> 16) & 0xFF) + "." + ((i >> 24)
            & 0xFF);
    }

     public static NetworkInfo.State getWifiConnectState(Context context) {
     ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context
            .CONNECTIVITY_SERVICE);
    if (manager == null) {
        return NetworkInfo.State.DISCONNECTED;
    }
    NetworkInfo mWiFiNetworkInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    if (mWiFiNetworkInfo != null) {
        return mWiFiNetworkInfo.getState();
    }
    return NetworkInfo.State.DISCONNECTED;
   }

But , it failed.

This code get only wifi IP . How can I get hotspot IP with this code.

How Can I transfer the screen with hotspot in java version?

dkrivoruchko commented 4 years ago

Look at this https://github.com/dkrivoruchko/ScreenStream/blob/master/data/src/main/kotlin/info/dvkr/screenstream/data/state/helper/NetworkHelper.kt That's all I can suggest.

ghost commented 4 years ago

Can you give any information for java?

I want to stream the screen with both wifi and hotspot with java Version.

https://github.com/dkrivoruchko/ScreenStream/blob/master/data/src/main/kotlin/info/dvkr/screenstream/data/state/helper/NetworkHelper.kt

Can I use the above kotlin class in java Version?

dkrivoruchko commented 4 years ago

You can. Or you can convert it to java