Skip to content

Instantly share code, notes, and snippets.

View sanjogshrestha's full-sized avatar

Sanjog Shrestha sanjogshrestha

View GitHub Profile
@sanjogshrestha
sanjogshrestha / Shared Preference Demo - Android
Created June 17, 2014 08:10
Shared Preference Demo - Android
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shared_preference);
et = (EditText) findViewById(R.id.editText1);
SharedPreferences sp = getSharedPreferences("MY_PREFERENCE", 0);
et.setText(sp.getString("default_value", ""));
/*
* @author Sanjog Shrestha
*/
public class Radio_Button_MainActivity extends Activity implements OnCheckedChangeListener
{
RadioGroup gender_group;
RadioButton male , female;
Button btnsubmit;
@sanjogshrestha
sanjogshrestha / Google Login In Android
Created July 24, 2014 10:13
Google Login In Android
//First you need to activate the Google+ API in Google Cloud Console and create a Project. Submit your SHA1 fingerprint ,package name in the newly formed ClientID . Remember - need to create a public key as well.
import java.io.Console;
import java.io.InputStream;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.content.Intent;
import android.content.IntentSender.SendIntentException;
import android.graphics.Bitmap;
@sanjogshrestha
sanjogshrestha / Enable or Disable Button in Android
Created July 26, 2014 16:12
Enable or Disable Button in Android
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button btn1=(Button)findViewById(R.id.button1);
Button btn2=(Button)findViewById(R.id.button2);
Button btn3=(Button)findViewById(R.id.button3);
@sanjogshrestha
sanjogshrestha / Generating SSH key in linux using terminal
Created August 13, 2014 10:19
Generating SSH key in linux using terminal
To check the ssh key already in the system : ls -al ~/.ssh
To generate the new SSH key : ssh-keygen -t rsa -C "your_email@example.com"
Press enter , enter for the all the prompt.
Check connectivity with github : ssh -T git@github.com
@sanjogshrestha
sanjogshrestha / Get Public IP in ubuntu in Terminal
Created August 13, 2014 10:21
Get Public IP in ubuntu in Terminal
$ curl ifconfig.me
(ip address)
@sanjogshrestha
sanjogshrestha / To get android key hash code
Created August 20, 2014 09:07
To get android key hash code and To get Certificate fingerprint(MD5)
To get android key hash code follow these steps
Download the openssl for windows
now unzip to c drive
open cmd prompt
type cd C:\Program Files\Java\jdk1.6.0_26\bin
then type only
keytool -export -alias myAlias -keystore C:\Users\your user name\.android\myKeyStore | C:\openssl-0.9.8k_WIN32 \bin\opens sl sha1 -binary | C:\openssl-0.9.8k_WIN32\bin\openssl enc -a -e
@sanjogshrestha
sanjogshrestha / Create SHA1 fingerprint in ubuntu from terminal
Created August 21, 2014 04:58
Create SHA1 fingerprint in ubuntu from terminal
In the terminal :
1> cd /usr/lib/jvm/java-7-openjdk-amd64/bin
2> keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
@sanjogshrestha
sanjogshrestha / adding maps using fragment
Created September 29, 2014 18:40
adding maps using fragment
LatLng HAMBURG = new LatLng(53.558, 9.927);
LatLng KIEL = new LatLng(53.551, 9.993);
GoogleMap map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
if (map !=null){
Log.d("FUApp", "Map isnt null");
Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG).title("Hamburg"));
Marker kiel = map.addMarker(new MarkerOptions()
.position(KIEL)
.title("Kiel")
@sanjogshrestha
sanjogshrestha / zooming maps in android
Created September 29, 2014 18:40
zooming maps in android
CameraPosition cameraPosition = new CameraPosition.Builder().target(latlng).zoom(14.0f).build();
CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition);
map.moveCamera(cameraUpdate);