Skip to content

Instantly share code, notes, and snippets.

View yerenutku's full-sized avatar

Eren Utku yerenutku

View GitHub Profile
@yerenutku
yerenutku / buttonların tüm xmlleri
Created February 11, 2017 19:09
iki button tüm xmlleri
layot
<LinearLayout
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<Button
android:id="@+id/btLeft"
android:layout_width="0dp"
public class UpdatingWidget extends AppWidgetProvider {
private PendingIntent service;
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
final AlarmManager manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
final Intent i = new Intent(context, UpdateService.class);
if (service == null) {
service = PendingIntent.getService(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
public class UpdateService extends Service {
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// generates random number
public class ConfigurableWidgetConfigureActivity extends Activity {
int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
private EditText etUrl;
private Button btAdd;
private AppWidgetManager widgetManager;
private RemoteViews views;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
public class BroadcastWidget extends AppWidgetProvider {
private static final String ACTION_SIMPLEAPPWIDGET = "ACTION_BROADCASTWIDGETSAMPLE";
private static int mCounter = 0;
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
int appWidgetId) {
// Construct the RemoteViews object
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.broadcast_widget);
// Construct an Intent which is pointing this class.
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.erenutku.simplewidgetexample"
xmlns:android="http://schemas.android.com/apk/res/android">
<application...>
...
<receiver android:name=".SimpleAppWidget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
public class SimpleAppWidget extends AppWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
// There may be multiple widgets active, so update all of them
for (int appWidgetId : appWidgetIds) {
updateAppWidget(context, appWidgetManager, appWidgetId);
}
}
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider
xmlns:android="http://schemas.android.com/apk/res/android"
android:initialKeyguardLayout="@layout/simple_app_widget"
android:initialLayout="@layout/simple_app_widget"
android:minHeight="60dp"
android:minWidth="60dp"
android:previewImage="@android:drawable/ic_menu_add"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="0"
@yerenutku
yerenutku / simple_app_widget.xml
Last active December 7, 2016 17:36
Medium Widget Code Blocks
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tvWidget"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/widget_margin"
android:background="#ff6200"