Skip to content

Instantly share code, notes, and snippets.

View ahmadmust8's full-sized avatar

Ahmad Mustafa ahmadmust8

  • in the cloud
View GitHub Profile
package Test_some_thing;
import java.util.ArrayList;
/**
* @author ahmad alalwi
*/
public class search_In_ArrayList
public class MainActivity extends Activity
{
Resources res = getResources();
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
package com.lakhanpal.ankit.alison;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.RelativeLayout;
import android.widget.Button;
import android.graphics.Color;
import android.widget.EditText;
@ahmadmust8
ahmadmust8 / onClickListener.java
Last active September 24, 2016 16:08
simple App it is change text color
// see http://imgur.com/a/cjk7N
package com.ahmad.mustafa.exercises;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
@ahmadmust8
ahmadmust8 / onOptionsItemSelected.java
Last active October 4, 2016 15:16
#onOptionsItemSelected Method.
package com.ahmad.mustafa.menuoption;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.RelativeLayout;
public class MainActivity extends AppCompatActivity
@ahmadmust8
ahmadmust8 / PermissionDemoActivity.java
Created April 7, 2017 01:14
Permissions requests by dialog for Android 6.0 or later
package ahmad.mostafa.permissiondemo;
import android.Manifest;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
@ahmadmust8
ahmadmust8 / LocationUpdatesBroadcastReceiver.java
Created May 3, 2017 00:48
Location Updates using a PendingIntent: Get updates about a device's location using a PendingIntent. Sample shows implementation using an IntentService as well as a BroadcastReceiver.
/**
* Copyright 2017 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStream
import java.io.InputStreamReader
import java.net.HttpURLConnection
import java.net.MalformedURLException
import java.net.URL
import java.nio.charset.Charset
import java.text.SimpleDateFormat
import java.util.Date
@ahmadmust8
ahmadmust8 / SharedPref.kt
Created July 20, 2018 02:54
very useful Class for Shared Preferences
class SharedPref(context: Context) {
private var sharedPreferences: SharedPreferences? =null
private var editor: SharedPreferences.Editor? =null
init {
val prefsFile = context.packageName
sharedPreferences = context.getSharedPreferences(prefsFile, Context.MODE_PRIVATE)
@ahmadmust8
ahmadmust8 / TimeUtils.kt
Last active February 22, 2019 02:17
Method To get Last Day Of Any Given Month
fun isLeapYear(year: Int): Boolean {
return year % 4 == 0
}
fun getLastDayOfMonth(month: Int,year: Int = 0) : Int {
when (month) {
JANUARY-> return 31
FEBRUARY-> {