Skip to content

Instantly share code, notes, and snippets.

View madhankumardroid's full-sized avatar
🎯
Focusing

Madhan Kumar S madhankumardroid

🎯
Focusing
  • Karur, TamilNadu, India
View GitHub Profile
@madhankumardroid
madhankumardroid / BiCycle.dart
Created January 20, 2019 14:59
An example in Dart based on BiCycle class Example in Java
class BiCycle {
int _speed = 0;
int gear;
int cadence;
BiCycle(this.gear, this.cadence);
int get speed => _speed;
void applyBrake(int decrement) {
void main() {
var x= 10.983747;
print(x.runtimeType);
String s = x.toString();
print(s);
String s1 = x.toStringAsFixed(1);
print(s1);
String name ="Madhan";
print("My name is ${name}");
@madhankumardroid
madhankumardroid / ListOfSensors
Created November 24, 2018 00:04
Get the list of sensors in Android
public class MainActivity extends AppCompatActivity {
ListView listView ;
SensorManager sensorManager ;
List<Sensor> listsensor;
List<String> liststring ;
ArrayAdapter<String> adapter ;
@Override
protected void onCreate(Bundle savedInstanceState) {
@madhankumardroid
madhankumardroid / StringExercise.kt
Last active August 5, 2018 03:41
Exercise for strings in Kotlin
var str: String = "Hello World!" //With type specification
var str1 = "Get started with Kotlin strings" //With out type specification
var str2 = str + ", "
var emptyString = String()//Creating an empty string
fun main(args: Array<String>) {
str2 += str1
println(str) //Result: Hello World!
println(str1) //Result: Get started with Kotlin strings
println(str2) //Result: Hello World!, Get started with Kotlin strings
@madhankumardroid
madhankumardroid / SaveDatabaseToSDCard
Created July 21, 2018 14:54
Save Database in SD Card
private void saveDBToSDCard() {
String databasePath = getActivity().getDatabasePath("Database.sqlite").getPath();
File f = new File(databasePath);
OutputStream myOutput = null;
InputStream myInput = null;
Log.d("testing", " testing db path " + databasePath);
Log.d("testing", " testing db exist " + f.exists());
if (f.exists()) {
try {
@madhankumardroid
madhankumardroid / gist:de86d74e7444ad2ee5ab590d8276cfc4
Created July 21, 2018 14:11
Get Language from Android Mobile
public String getLanguage() {
Locale locale = Locale.getDefault();
String country = locale.getCountry();
StringBuffer language = new StringBuffer(locale.getLanguage());
language.append("-");
language.append(country);
return language.toString().toLowerCase();
}
@madhankumardroid
madhankumardroid / NetworkActivity.java
Created July 21, 2018 13:22
Network broadcast receiver
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.v7.app.AppCompatActivity;
public class NetworkActivity extends AppCompatActivity {
class NetworkBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Open Terminal and type in..
nano ~/.bash_profile
Add the below paths
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
Type source $HOME/.bash_profile to load the config into your current shell. Verify that ANDROID_HOME has been added to your path by running echo $PATH.