Skip to content

Instantly share code, notes, and snippets.

@aldoKelvianto
aldoKelvianto / Connect Url Proxy.md
Last active January 4, 2018 17:49
HttpUrlConnection with Proxy (and authentication) for Android

How to enable your app connected to internet using proxy. Note: this only works http, still working on https.

private String fetchUsingProxy() throws IOException {
    URL url = new URL("http://www.google.com");

    Authenticator authenticator = new Authenticator() {
        @Override
        protected PasswordAuthentication getPasswordAuthentication() {
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- google's material design colours from
http://www.google.com/design/spec/style/color.html#color-ui-color-palette -->
<!--reds-->
<color name="md_red_50">#FFEBEE</color>
<color name="md_red_100">#FFCDD2</color>
<color name="md_red_200">#EF9A9A</color>
package com.aldoapps.popularmovies;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Environment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
private String saveImageToInternalDrive() {
Bitmap bitmap;
OutputStream outputStream;
bitmap = ((BitmapDrawable) mImageView.getDrawable()).getBitmap();
File filePath = getFilesDir();
File imageDir = new File(filePath.getAbsolutePath() + "YourDirName");
if(!imageDir.exists()){
private void experimentPostQuestion(){
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(new Interceptor() {
@Override
public okhttp3.Response intercept(Chain chain) throws IOException {
String userName = "admin";
String password = "pass";
String base64EncodedCredentials = "Basic " + Base64.encodeToString(
(userName + ":" + password).getBytes(),
@aldoKelvianto
aldoKelvianto / PopUpFragment
Created January 28, 2015 18:15
Line-like Pop Up Menu
package com.bixbox.ui.brand;
import android.app.Dialog;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
@aldoKelvianto
aldoKelvianto / GameMain.cs
Last active December 5, 2016 19:08
Loading 3D Model XNA snippet
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
public class GameMain : Microsoft.Xna.Framework.Game {
GraphicsDeviceManager graphics;
@aldoKelvianto
aldoKelvianto / HelloWorld.rb
Last active December 20, 2015 11:39
Hello World in RGSS
class HelloWorld < Window_Base
$kata1 = "The quick brown fox"
$kata2 = "Jumps over the lazy dog"
def initialize
super(0,0, 200, 200)
refresh
end
class HeroIndex
$indexHero
def initialize(index)
$indexHero = index
end
end