Skip to content

Instantly share code, notes, and snippets.

View wangerekaharun's full-sized avatar

Harun Wangereka wangerekaharun

View GitHub Profile
87DQC-G8CYR-CRPJ4-QX9K8-RFV2B ( Ultimate Version)
KCQWK-Q43V3-M3F2T-83VGV-Y6VTX (Professional Version)
TTDB9-9YPYH-7FBVY-X2CTQ-D8F2H (Test Professional Version)
P27TG-XXX2W-XK8TK-QD9FK-V36W4 (Premium & Express Version)
6T3MC-YX8XF-7CWXW-462TQ-8G2B4 (Team Foundation Server)
@wangerekaharun
wangerekaharun / OnItemSelectedListener.java
Created August 28, 2017 06:52 — forked from andreynovikov/OnItemSelectedListener.java
Complete working solution for Android action bar tabs with fragments having separate back stack for each tab.
// Custom interface that enables communication between Fragment and its Activity
public interface OnItemSelectedListener
{
public void onItemSelected(String item);
}
@wangerekaharun
wangerekaharun / Android Read SMS
Created October 16, 2017 05:33
Code for reading SMS in android
//add permission Read SMS in android manifest to enable this code to work
StringBuilder smsBuilder = new StringBuilder();
final String SMS_URI_INBOX = "content://sms/inbox";
final String SMS_URI_ALL = "content://sms/";
try {
Uri uri = Uri.parse(SMS_URI_ALL);
String[] projection = new String[] { "_id", "address", "person", "body", "date", "type" };
//retrieving sms for a particular number,you can set to null so as to read all sms in inbox folder
<?php
include 'db.php';
// json response array
$response = array("error" => FALSE);
if (isset($_POST['email']) && isset($_POST['password'])) {
// receiving the post paramss
$email = $MySQLi_CON->real_escape_string(trim($_POST['email']));
package ke.co.appslab.callsledger.Services;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.IBinder;
import android.support.annotation.IntDef;
import android.support.annotation.Nullable;
import android.widget.Toast;
@wangerekaharun
wangerekaharun / BusinessDummyData.java
Last active January 6, 2018 12:34
Android Dummy Data example
package com.wangerekaharun.eldoclassified.Utils;
import com.wangerekaharun.eldoclassified.Models.Business;
import java.util.ArrayList;
import java.util.List;
/**
* Created by harun on 8/31/17.
*/
@wangerekaharun
wangerekaharun / BackgroundService.java
Last active January 10, 2018 10:25
Intent Service class which sends a broadcast after every 15 minutes
public class BackgroundService extends IntentService {
public static final String ACTION="ke.co.appslab.androidbackgroundservices.Receivers.ResponseBroadcastReceiver";
// Must create a default constructor
public BackgroundService() {
// Used to name the worker thread, important only for debugging.
super("backgroundService");
}
@Override
@wangerekaharun
wangerekaharun / ScheduleAlarm
Created January 10, 2018 09:49
Schedule an alarm that repeats every 15 minutes
Intent toastIntent= new Intent(getApplicationContext(),ToastBroadcastReceiver.class);
PendingIntent toastAlarmIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, toastIntent,PendingIntent.FLAG_UPDATE_CURRENT);
long startTime=System.currentTimeMillis(); //alarm starts immediately
AlarmManager backupAlarmMgr=(AlarmManager)this.getSystemService(Context.ALARM_SERVICE);
backupAlarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP,startTime,AlarmManager.INTERVAL_FIFTEEN_MINUTES,toastAlarmIntent); // alarm will repeat after every 15 minutes
@wangerekaharun
wangerekaharun / ScheduleAlarm
Created January 10, 2018 09:50
Create an alarm that repeats every 15 minutes
Intent toastIntent= new Intent(getApplicationContext(),ToastBroadcastReceiver.class);
PendingIntent toastAlarmIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, toastIntent,PendingIntent.FLAG_UPDATE_CURRENT);
long startTime=System.currentTimeMillis(); //alarm starts immediately
AlarmManager backupAlarmMgr=(AlarmManager)this.getSystemService(Context.ALARM_SERVICE);
backupAlarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP,startTime,AlarmManager.INTERVAL_FIFTEEN_MINUTES,toastAlarmIntent); // alarm will repeat after every 15 minutes
@wangerekaharun
wangerekaharun / ToastBroadcastReceiver.java
Created January 10, 2018 09:54
Starting the intentservice in the OnReceive method of the ToastBroadcastReceiver
public class ToastBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent serviceIntent= new Intent(context,BackgroundService.class);
context.startService(serviceIntent);
}
}