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
class PowerConnectionReceiver: BroadcastReceiver() { | |
override fun onReceive(context: Context, intent: Intent) { | |
val status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1) | |
val isCharging = ((status == BatteryManager.BATTERY_STATUS_CHARGING) || | |
status == BatteryManager.BATTERY_STATUS_FULL) | |
val isUnknown = (status == BatteryManager.BATTERY_STATUS_UNKNOWN) | |
val hasBeenDisconnected = (status == BatteryManager.BATTERY_STATUS_DISCHARGING) | |
} |
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
private fun fireBroadcastReceiverExplicitly() { | |
val intent = Intent("brendan.wattsapp.debug") | |
sendBroadcast(intent) | |
} |
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
<receiver android:name=".PowerConnectionReceiver"> | |
<intent-filter> | |
<action android:name="android.intent.action.ACTION_POWER_CONNECTED"/> | |
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED"/> | |
<action android:name="brendan.wattsapp.debug"/> | |
</intent-filter> | |
</receiver> |
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
// Adding a local project as a Gradle dependency | |
// In the consuming project's settings.gradle | |
include ':japi' | |
project(':japi').projectDir = file("../zendesk_java_client") | |
// The dependency | |
compile project(':japi') |
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
import android.content.DialogInterface; | |
import android.content.pm.PackageManager; | |
import android.os.Bundle; | |
import android.os.Parcel; | |
import android.os.Parcelable; | |
import android.support.annotation.NonNull; | |
import android.support.v13.app.FragmentCompat; | |
import android.support.v4.app.ActivityCompat; | |
import android.support.v4.app.Fragment; | |
import android.support.v4.content.ContextCompat; |
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
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
MenuInflater menuInflater = getMenuInflater(); | |
menuInflater.inflate(R.menu.airports, menu); | |
searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search)); | |
searchView.setIconified(false); | |
searchView.setOnQueryTextListener(searchQueryTextListener); | |
searchView.setQuery("", false); | |
return true; |
NewerOlder