This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by Pedro Massango on 5/28/18. | |
*/ | |
class AlarmBroadcastReceiver : BroadcastReceiver() { | |
override fun onReceive(context: Context?, intent: Intent?) { | |
// Create the notification to be shown | |
val mBuilder = NotificationCompat.Builder(context!!, "my_app") | |
.setSmallIcon(R.mipmap.ic_launcher) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set an alarm to trigger 5 second after this code is called | |
alarmMgr.set( | |
AlarmManager.RTC_WAKEUP, | |
System.currentTimeMillis() + 5000, | |
pIntent | |
) // stop here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Request the AlarmManager object | |
val manager = getSystemService(Context.ALARM_SERVICE) as AlarmManager | |
// Create the PendingIntent that would have launched the BroadcastReceiver | |
val pending = PendingIntent.getBroadcast( | |
this, 0, | |
Intent(this, AlarmBroadcastReceiver::class.java), 0 | |
) | |
// Cancel the alarm associated with that PendingIntent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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="match_parent" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:orientation="vertical" | |
android:background="@color/colorPrimary"> | |
<!--a toolbar to open/close action--> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SampleActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_sample) | |
// set toolbar as actionBar | |
setSupportActionBar(home_toolbar) | |
title = " " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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:background="@color/colorPrimary" | |
android:orientation="vertical"> | |
<TextView | |
android:id="@+id/dialog_title" | |
android:layout_width="wrap_content" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
Widget build(BuildContext context) { | |
return new Container( | |
color: Colors.white, | |
child: Column( | |
children: <Widget>[ | |
Spacer(), | |
Hero( /// Hero | |
tag: 'logo', | |
child: Image.asset('images/icon_like.png'), /// This is the flying widget |