Skip to content

Instantly share code, notes, and snippets.

View DanishAmjad12's full-sized avatar
🎯
Focusing

Danish DanishAmjad12

🎯
Focusing
View GitHub Profile
<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" />
class AlarmJobIntentService : JobIntentService() {
override fun onHandleWork(intent: Intent) {
/* your code here */
/* reset the alarm */
// Util.showDebugLog("setAlarmCtx", "started Bottom")
AlarmReceiver.setAlarm(false)
stopSelf()
}
class AlarmReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
/* enqueue the job */
AlarmJobIntentService.enqueueWork(context, intent)
}
companion object {
<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>
<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" />
<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.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"
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@id/menu_action_search"
android:orderInCategory="1"
android:icon="@drawable/ic_menu_search_blue"
app:iconTint="#008aff"
app:showAsAction="always"
app:actionViewClass="android.support.v7.widget.SearchView"
android:title="@string/menu_search"/>
private int clickedNavItem = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
/**