Skip to content

Instantly share code, notes, and snippets.

View pedromassango's full-sized avatar

Pedro Massango pedromassango

View GitHub Profile
/**
* 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)
// Set an alarm to trigger 5 second after this code is called
alarmMgr.set(
AlarmManager.RTC_WAKEUP,
System.currentTimeMillis() + 5000,
pIntent
) // stop here
// 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
<android.support.design.button.MaterialButton
android:text="Messages"
android:textColor="#fff"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<?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-->
class SampleActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sample)
// set toolbar as actionBar
setSupportActionBar(home_toolbar)
title = " "
@pedromassango
pedromassango / scafold-with-bottomNavigationBar.dart
Last active September 2, 2018 21:27
Flutter app, setup an BottomNavigationBar
Scaffold(
bottomNavigationBar: BottomNavigationBar(
currentIndex: 0,
fixedColor: Colors.black,
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: new Icon(Icons.home),
title: new Text("")
),
BottomNavigationBarItem(
import 'package:flutter/material.dart';
import 'new_task.dart';
void main() => runApp(new TaskyApp());
final mTitle = "Tasks";
class TaskyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
<?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"
@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