Skip to content

Instantly share code, notes, and snippets.

View rocboronat's full-sized avatar

Roc Boronat rocboronat

View GitHub Profile
@rocboronat
rocboronat / BaseActivity.java
Last active April 13, 2016 08:16
Calling setTaskDescription() in a reflected way
private void setTaskDescription(){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
String title = getString(R.string.app_name);
Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
int color = getResources().getColor(R.color.task_background);
// The legacy method call
// setTaskDescription(new ActivityManager.TaskDescription(title, icon, color));
// The reflected method call
@rocboronat
rocboronat / SomeActivity.java
Last active August 29, 2015 14:06
Show a PopupWindow with negative margin on a MenuItem of the ActionBar
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_listoffers, menu);
new Handler().post(new Runnable() {
@Override
public void run() {
final View menuItemView = findViewById(R.id.action_search);
@rocboronat
rocboronat / dimens.xml
Last active June 30, 2018 19:04
A basic dimens.xml for Android, with applied Android Design guidelines
<resources>
<!-- http://developer.android.com/design/style/metrics-grids.html -->
<dimen name="gap_small">4dp</dimen>
<dimen name="gap_medium">8dp</dimen>
<dimen name="gap_large">16dp</dimen>
<dimen name="gap_xlarge">32dp</dimen>
<dimen name="gap_xxlarge">64dp</dimen>
<!-- http://developer.android.com/design/style/typography.html -->
@rocboronat
rocboronat / BluetoothUtil.java
Last active March 5, 2018 07:24
Some Bluetooth Android actions
package net.rocboronat.android.utils;
import java.lang.reflect.Method;
import java.util.Set;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.util.Log;
public class BluetoothUtil {