This file contains hidden or 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
@Override | |
public boolean onOptionsItemSelected(MenuItem item) { | |
switch (item.getItemId()) { | |
case android.R.id.home: | |
Toast.makeText(getApplicationContext(),"Back button clicked", Toast.LENGTH_SHORT).show(); | |
break; | |
} | |
return true; | |
} |
This file contains hidden or 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 boolean isNetworkAvailable(Context context) { | |
ConnectivityManager connectivityManager | |
= (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | |
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); | |
return activeNetworkInfo != null && activeNetworkInfo.isConnected(); | |
} |
This file contains hidden or 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 main(String[] args) { | |
ClassLoader loader = ClassLoader.getSystemClassLoader(); | |
File f = new File(loader.getResource("file_name.txt").getFile()); | |
try (Scanner scanner = new Scanner(f)){ | |
scanner.useDelimiter(";"); |
This file contains hidden or 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
@Override | |
public boolean onOptionsItemSelected(MenuItem item) { | |
switch (item.getItemId()) { | |
case android.R.id.home: | |
Toast.makeText(getApplicationContext(),"Back button clicked", Toast.LENGTH_SHORT).show(); | |
break; | |
} | |
return true; | |
} |
This file contains hidden or 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
ssh root@MachineB 'bash -s' < local_script.sh | |
PID=`ps -ef | grep rest-ser | grep -v grep | awk '{print $2}'` | |
#!/bin/bash | |
PID=`ps -ef | grep rest-ser | grep -v grep | awk '{print $2}'` | |
echo $PID |
This file contains hidden or 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 openPlayMarketByPackageName(Context ctx, String packageName) { | |
try { | |
ctx.startActivity(new Intent(Intent.ACTION_VIEW, | |
Uri.parse("market://details?id=" + packageName))); | |
} catch (android.content.ActivityNotFoundException anfe) { | |
ctx.startActivity(new Intent(Intent.ACTION_VIEW, | |
Uri.parse("https://play.google.com/store/apps/details?id=" + packageName))); | |
} catch (Exception ex) { | |
ex.printStackTrace(); |
This file contains hidden or 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
#!/usr/bin/python | |
n = 11 | |
while n != 1: | |
print n | |
if n % 2 == 0: | |
n /= 2 | |
else: | |
n = 3 * n + 1 |
This file contains hidden or 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 String getDeviceId(Context ctx) { | |
TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); | |
String deviceId; | |
if (tm.getDeviceId() != null) { | |
deviceId = tm.getDeviceId(); | |
} else { |
This file contains hidden or 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 String getDeviceId(Context ctx) { | |
TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); | |
String deviceId; | |
if (tm.getDeviceId() != null) { | |
deviceId = tm.getDeviceId(); | |
} else { |