Skip to content

Instantly share code, notes, and snippets.

View Tonnie-Dev's full-sized avatar
🏠
Working from home

Tonnie Tonnie-Dev

🏠
Working from home
View GitHub Profile
@Tonnie-Dev
Tonnie-Dev / java.java
Created July 30, 2018 17:57
Android Test
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
colorClass = new ColorClass();
factClass = new FactClass();
layout = findViewById(R.id.relativeLayout);
txt = findViewById(R.id.textFact);
btn = findViewById(R.id.btn);
@Tonnie-Dev
Tonnie-Dev / java.java
Created August 2, 2018 08:08
buildTypes Block
buildTypes {
release {
postprocessing {
removeUnusedCode true
removeUnusedResources true
obfuscate true
optimizeCode true
proguardFile 'proguard-rules.pro'
}
}
@Tonnie-Dev
Tonnie-Dev / java.java
Created August 2, 2018 08:16
proguard-rules.pro
-assumenosideeffects class android.util.Log{
public static boolean isLoggable(java.lang.String, int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
}
@Tonnie-Dev
Tonnie-Dev / java.java
Created August 3, 2018 08:59
Context Start Activity
/*provide context if MyActivity is a local activity*/
Intent intent = new Intent(context,MyActivity.class);
startActivity(intent);
@Tonnie-Dev
Tonnie-Dev / java.java
Created August 3, 2018 09:15
getResourses
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/*this references to the activity's class*/
String [] animal = this.getResources().getStringArray(R.array.animals);
}
}
@Tonnie-Dev
Tonnie-Dev / java.java
Created August 3, 2018 09:22
getSystem Services
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*getting a notification service*/
NotificationManager notificationManager = (NotificationManager) getSystemService(Context
.NOTIFICATION_SERVICE);
}
@Tonnie-Dev
Tonnie-Dev / java.java
Created August 3, 2018 09:31
internal File Path
File file = new File(context.getFilesDir(), filename);
@Tonnie-Dev
Tonnie-Dev / java.java
Created August 3, 2018 09:43
dynamic TextView
/*creating a dynamic textview*/
TextView textView = new TextView(MainActivity.this);
@Tonnie-Dev
Tonnie-Dev / java.java
Created August 3, 2018 09:45
inflating XML Layout
/*inflating xml layout*/
LayoutInflater layoutInflater = LayoutInflater.from(MainActivity.this);
layoutInflater.inflate(R.layout.activity_main,parent, false);
@Tonnie-Dev
Tonnie-Dev / java.java
Created August 3, 2018 09:49
Sending Local Broadcast
/*sending local broadcast*/
Intent broadcastIntent = new Intent("custom-intent");
LocalBroadcastManager.getInstance(context).sendBroadcast(broadcastIntent);