launcher icon / sms / manager on boot
@@ -4,7 +4,8 @@
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@@ -19,40 +20,51 @@
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<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" />
|
||||
<data android:scheme="https" />
|
||||
<data android:host="agrar.zoblak.com" />
|
||||
<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" />
|
||||
<data android:scheme="https" />
|
||||
<data android:host="agrar.zoblak.com" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name=".AlarmPollingService"
|
||||
android:exported="false" />
|
||||
|
||||
<service
|
||||
android:name=".SoundPlayingService"
|
||||
android:exported="false" />
|
||||
|
||||
<receiver
|
||||
android:name="PeriodicalPingReceiver"
|
||||
android:name=".PeriodicalPingReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true" />
|
||||
|
||||
<activity
|
||||
android:screenOrientation="portrait"
|
||||
android:name=".SettingsActivity"
|
||||
android:label="@string/title_activity_settings"
|
||||
android:parentActivityName=".MainScreen">
|
||||
android:parentActivityName=".MainScreen"
|
||||
android:screenOrientation="portrait">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.zoblak.farmalarm.MainScreen" />
|
||||
</activity>
|
||||
|
||||
<receiver
|
||||
android:name=".BootBroadcastReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.zoblak.farmalarm;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
public class BootBroadcastReceiver extends BroadcastReceiver {
|
||||
public BootBroadcastReceiver() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
MainScreen.setupAlarmManager(context);
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,7 @@ import java.lang.System;
|
||||
|
||||
public class MainScreen extends AppCompatActivity {
|
||||
|
||||
private AlarmManager alarmMgr;
|
||||
private PendingIntent alarmIntent;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -29,24 +28,25 @@ public class MainScreen extends AppCompatActivity {
|
||||
setContentView(R.layout.activity_main_screen);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show();
|
||||
}
|
||||
});
|
||||
|
||||
Intent intent = new Intent(this, PeriodicalPingReceiver.class);
|
||||
|
||||
alarmIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
|
||||
setupAlarmManager(this);
|
||||
|
||||
|
||||
int PERIOD_IN_MS = 5 * 60 * 1000; // 5 minutes
|
||||
|
||||
alarmMgr = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
|
||||
}
|
||||
|
||||
public static void setupAlarmManager(Context context) {
|
||||
AlarmManager alarmMgr;
|
||||
|
||||
PendingIntent alarmIntent;
|
||||
|
||||
Intent intent = new Intent(context, PeriodicalPingReceiver.class);
|
||||
|
||||
alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
|
||||
|
||||
|
||||
int PERIOD_IN_MS = 2 * 60 * 1000; // 2 minutes
|
||||
|
||||
alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
|
||||
// Hopefully your alarm will have a lower frequency than this!
|
||||
alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP,
|
||||
System.currentTimeMillis(),
|
||||
|
||||
@@ -23,12 +23,4 @@
|
||||
|
||||
<include layout="@layout/content_main_screen" />
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
app:srcCompat="@android:drawable/ic_dialog_email" />
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 14 KiB |