Skip to content

Instantly share code, notes, and snippets.

@codeswimmer
codeswimmer / Android.Bitmap.Rotate
Created March 7, 2011 17:25
Android: rotate a bitmap
public Bitmap rotateBitmap(Bitmap original, float degrees) {
int width = original.getWidth();
int height = original.getHeight();
Matrix matrix = new Matrix();
matrix.preRotate(degrees);
Bitmap rotatedBitmap = Bitmap.createBitmap(original, 0, 0, width, height, matrix, true);
Canvas canvas = new Canvas(rotatedBitmap);
canvas.drawBitmap(original, 5.0f, 0.0f, null);
@vinigracindo
vinigracindo / gist:5388567
Created April 15, 2013 14:37
Android Download Image from URL
package utils;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
@grantland
grantland / post.md
Last active February 9, 2023 05:09
RecyclerView item onClick

RecyclerView item onClick

RecyclerView does not have an OnItemClickListener like it's predecessor, ListView. However, detecting item clicks is pretty simple.

Set an OnClickListener in your ViewHolder creation:

private class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder>  {

    public static class ViewHolder extends RecyclerView.ViewHolder
@liu7yong
liu7yong / WifiConnection.java
Last active November 7, 2021 14:45
How to connect to a specific wifi network in Android programmatically?
WifiConfiguration wifiConfig = new WifiConfiguration();
wifiConfig.SSID = String.format("\"%s\"", ssid);
wifiConfig.preSharedKey = String.format("\"%s\"", key);
WifiManager wifiManager = (WifiManager)getSystemService(WIFI_SERVICE);
//remember id
int netId = wifiManager.addNetwork(wifiConfig);
wifiManager.disconnect();
wifiManager.enableNetwork(netId, true);
wifiManager.reconnect();
@lopspower
lopspower / README.md
Last active March 25, 2026 13:19
All Android Directory Path

All Android Directory Path

Twitter

1) System directories

⚠️ We can't write to these folers

Method Result
@FrantisekGazo
FrantisekGazo / StatefulRecyclerView.java
Last active April 19, 2026 19:25
Retain & restore recycler view scroll position
package eu.f3rog.ui.custom;
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
/**
@pixelbrackets
pixelbrackets / api.php
Last active January 11, 2025 09:07
Simple PHP script to test and use cURL
<?php
/**
* Simple request response script
*
* Point you cURL request to this script to see all incoming data
*/
echo '*API*'. PHP_EOL;
@abdurrahmanekr
abdurrahmanekr / gist:2747d704edec93a06e454eba2653e0df
Last active March 26, 2026 19:51
WhatsApp original chat background image

WhatsApp original chat background image

WhatsApp original darkmoda background image

@PasanBhanu
PasanBhanu / AndroidDownloadImage.java
Created September 26, 2019 09:04
Download Image from URL and Added to Gallery - Android (Java)
/*
This method can be used to download an image from the internet using a url in Android. This use Android Download Manager to
download the file and added it to the Gallery. Downloaded image will be saved to "Pictures"
Folder in your internal storage
*/
private void downloadImageNew(String filename, String downloadUrlOfImage){
try{
DownloadManager dm = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
Uri downloadUri = Uri.parse(downloadUrlOfImage);
@colesnicov
colesnicov / ftoa.c
Last active September 22, 2023 11:25
Float to string conversion for AVR's devices and over embedded MCU's..
/**
* @Licence WTFPL
*/
#include "ftoa.h"
int ftoa(float f, char *p, uint8_t precision)
{
typedef union