Skip to content

Instantly share code, notes, and snippets.

View DanishAmjad12's full-sized avatar
🎯
Focusing

Danish DanishAmjad12

🎯
Focusing
View GitHub Profile
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<style name="AppTheme.Toolbar" parent="AppTheme">
<!--This line changes the color of text in Toolbar-->
<item name="android:textColorPrimary">@color/green</item>
<!--This line changes the color of icons in toolbar (back, overflow menu icons)-->
<item name="android:textColorSecondary">@color/green</item>
</style
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:theme="@style/AppTheme.Toolbar" />
<activity ...>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="www.example.com" />
<data android:scheme="https" />
</intent-filter>
class AlarmReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
/* enqueue the job */
AlarmJobIntentService.enqueueWork(context, intent)
}
companion object {
class AlarmJobIntentService : JobIntentService() {
override fun onHandleWork(intent: Intent) {
/* your code here */
/* reset the alarm */
// Util.showDebugLog("setAlarmCtx", "started Bottom")
AlarmReceiver.setAlarm(false)
stopSelf()
}
<receiver android:name=".AlarmReceiver"
android:permission="android.permission.BIND_JOB_SERVICE">
<intent-filter>
<action android:name="com.test.intent.action.ALARM" />
</intent-filter>
</receiver>
<service android:name=".AlarmJobIntentService" />
Notification notification = new NotificationCompat.Builder(this);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
notification.setSmallIcon(R.drawable.icon_transperent);
notification.setColor(getResources().getColor(R.color.notification_color));
} else {
notification.setSmallIcon(R.drawable.icon);
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<Button
android:layout_width="wrap_content"