This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by alik on 3/31/17. | |
*/ | |
public class Main { | |
// TODO: Support other EndOfLines, like "\r\n". | |
// One way is to just replace all "\r\n" with "\n" and then run the @getLastLines method. | |
public static List<String> getLastLines(String string, int numLines) { | |
List<String> lines = new ArrayList<>(); | |
int currentEndOfLine = string.length(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package kilaka; | |
public class LambdaUtil { | |
/** | |
* Works only with Java 8. | |
*/ | |
@SuppressWarnings("unchecked") | |
public static <T extends Throwable> RuntimeException rethrowSneaky(Throwable throwable) throws T { | |
throw (T) throwable; // rely on vacuous cast |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void runServer() { | |
try { | |
MulticastSocket s = new MulticastSocket(4446); | |
InetAddress group = InetAddress.getByName("224.0.0.10"); | |
s.joinGroup(group); | |
byte[] data = new byte[100]; | |
DatagramPacket datagramPacket = new DatagramPacket(data, data.length); | |
s.receive(datagramPacket); | |
Log.i("Received: " + data); | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void runServer() { | |
try { | |
DatagramSocket s = new DatagramSocket(8888); | |
byte[] data = new byte[100]; | |
DatagramPacket datagramPacket = new DatagramPacket(data, data.length); | |
s.receive(datagramPacket); | |
Log.i("Received: " + data); | |
return; | |
} catch (Exception e) { | |
Log.e("", e); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<activity android:name="info.fastpace.android.sample.LocalServiceBindingDemo$SampleActivity"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity> | |
<service android:name="info.fastpace.android.sample.LocalServiceBindingDemo$MyService"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<activity android:name="info.fastpace.android.sample.LocalServiceBindingDemo$SampleActivity"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity> | |
<service android:name="info.fastpace.android.sample.LocalServiceBindingDemo$MyService"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package info.fastpace.android.sample; | |
import java.lang.reflect.InvocationHandler; | |
import java.lang.reflect.Method; | |
import java.lang.reflect.Proxy; | |
import android.app.Activity; | |
import android.app.Service; | |
import android.content.ComponentName; | |
import android.content.Context; |