Skip to content

Instantly share code, notes, and snippets.

@romrozen
romrozen / acb_connect_over_wifi
Created April 14, 2018 13:43
Connect android device and debug over WiFi.
1.Run in the terminal - adb tcpip 5555
2.Run in the terminal - adb connect <IP>:5555
* First step only needed if device was restarted.
* To disconnect WiFi connection run step 2 but with disconnect keyword instead.
* IP - can be found in the WiFi setting of the device.
private void uploadShotToFirebase() {
final String path = "UserImages/" + UUID.randomUUID() + ".png";
StorageReference imagesRef = mFirebaseStorage.getReference(path);
StorageMetadata imageMetaData = new StorageMetadata.Builder().setCustomMetadata("text2", "some metadata2").build();
//show progress circle, disable upload button
UploadTask uploadTask = imagesRef.putBytes(bitmapInByteArray, imageMetaData);
uploadTask.addOnSuccessListener(getActivity(),new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
<LinearLayout
android:weightSum="60"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_weight="20"
android:layout_width="match_parent"
@romrozen
romrozen / HashCreation.java
Last active December 9, 2017 20:14
Hash creation for Facebook API.
private void generateHash() {
try {
PackageInfo info = getPackageManager().getPackageInfo(
BuildConfig.APPLICATION_ID,// change to the main package name!!
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
public class MainClass {
public static void main(String[] args) {
//randomEx();
//consequentialOddSum();
//arry1DQ1();
//arry1DQ4();
@romrozen
romrozen / JSON with gson
Last active August 29, 2015 14:23
parsing JSON with gson, model example
package com.example.test.models;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
public class SomeModel{
@SerializedName("search_results") //The exact string that will be in the parsed JSON
private SearchResults searchResults;//We see that the parsed item is an object and not a simple variable, another Model with the name "SearchResults" is created with the same procedure as in this document