Skip to content

Instantly share code, notes, and snippets.

View alitamoor65's full-sized avatar
💭
I may be slow to respond.

Ali Tamoor alitamoor65

💭
I may be slow to respond.
  • Soft Logix
  • Multan, Pakistan
View GitHub Profile
@alitamoor65
alitamoor65 / WriteToFile.java
Created March 29, 2019 05:37
A method to write into file, append data to new line each time separated by comma in java
class WriteToFile{
BufferedWriter bw;
public void writeFile1(String number){
File fout = new File(Environment.getExternalStorageDirectory() + "/numbers0300.cvs");
FileOutputStream fos = null;
try {
fos = new FileOutputStream(fout);
bw = new BufferedWriter(new OutputStreamWriter(fos));
bw.write(number + ",");
Log.i(TAG, "writeFile1: " + number);
@alitamoor65
alitamoor65 / DownloadAudioAndPlay.java
Created January 3, 2019 10:32
DownloadAudioAndPlay.java
package com.example.alitamoor.downloadersampleapplication;
import android.media.MediaPlayer;
import android.os.AsyncTask;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ProgressBar;
@alitamoor65
alitamoor65 / gist:5b46b4af3974523b3a2c99904e48c814
Created December 28, 2018 07:09 — forked from mstfldmr/gist:f6594b2337e3633673e5
Example of Volley GET and POST requests with parameters and headers
RequestQueue queue = Volley.newRequestQueue(context);
//for POST requests, only the following line should be changed to
StringRequest sr = new StringRequest(Request.Method.GET, "http://headers.jsontest.com/",
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.e("HttpClient", "success! response: " + response.toString());
}
},
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/login_bg"
tools:context=".activities.LoginActivity">
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
@alitamoor65
alitamoor65 / Manifest.xml
Last active October 9, 2018 07:11
Follow the step the make it done 1. Create a java class and name `UnlockReceiver.java` whatever you want :) 2. Add the following `UnlockReceiver.java` code in your whatever java class 3. Register your receiver in your manifest file by adding following lines ```java <receiver android:name=".textonphoto.AdsControler.UnlockReceiver.java" android:en…
<receiver
android:name=".textonphoto.AdsControler.UnlockReceiver.java"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.SCREEN_OFF" />
<action android:name="android.intent.action.SCREEN_ON" />
<action android:name="android.intent.action.USER_PRESENT" />
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
@alitamoor65
alitamoor65 / PressAgainToExit.java
Created April 10, 2018 03:14
Press Again To Exit With Timer
private long lastPressedTime;
private static final int PERIOD = 2000;
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
switch (event.getAction()) {
case KeyEvent.ACTION_DOWN:
if (event.getDownTime() - lastPressedTime < PERIOD) {
finish();
@alitamoor65
alitamoor65 / Manifest.xml
Created April 10, 2018 03:12
Request and Check RunTime Permissions
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tutorialscafe.readallsms">
<uses-permission android:name="android.permission.READ_CONTACTS" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
@alitamoor65
alitamoor65 / ShareAppLink.java
Created April 9, 2018 17:06
Share Android App click
@alitamoor65
alitamoor65 / CopyFromAssetsToSDCard.java
Created April 9, 2018 17:00
Copy All Files from Assets to SD Card
private String storeImage(Bitmap bitmap,String fileName){
String dirPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/FilterImages";
File dir = new File(dirPath);
if(!dir.exists()){
dir.mkdir();
}
File file = new File(dirPath,fileName);
try{
FileOutputStream fileOutputStream = new FileOutputStream(file);
@alitamoor65
alitamoor65 / FrameChooserActivity.xml
Last active April 9, 2018 17:08
Grid View From Local Storage
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/main_bg"
tools:context="pk.camict.jovial.eidmubarakprofile.FrameChosserActivity"
android:gravity="center">