Escolar Documentos
Profissional Documentos
Cultura Documentos
----------------------
implementation 'com.android.support:support-v4:28.0.0' ///must add this if show
error
-----------------------------------------------------------------------------------
----------------------
lintOptions{
checkReleaseBuilds false
-----------------------------------------------------------------------------------
----------------------
it is code for the optimise the code size reduce size of app write in -> andriod{}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
debug {
minifyEnabled false
}
}
-----------------------------------------------------------------------------------
---------------------
Ripple Effects :
android:foreground="?android:selectableItemBackground"
cardview:
app:contentPadding="16dp"
-----------------------------------------------------------------------------------
---------------------
-
this is onclicklistner->
another Method
Intent intent = new Intent(Main2Activity.this,
ScrollingActivity.class);
startActivity(intent);
//uri
intent.setData(Uri.parse("https://play.google.com/store/apps/details?
id=com.google.android.youtube"));
startActivity(intent);
////URI
intent.setData(Uri.parse("https://www.youtube.com/channel/UCnd_t61oAOm8n_dQUki4MaA"
));
context.startActivity(intent);
-----------------------------------------------------------------------------------
----------------------
andriodhive
Snackbar
make(view,"Welcome to Java Academy", Snackbar.LENGTH_LONG);
Snackbar.make(view, getString(R.string.main_flat_button_2_clicked),
Snackbar.LENGTH_SHORT).show();
-----------------------------------------------------------------------------------
----------------------
java code:
WebView myWebView = (WebView) findViewById(R.id.web_source_licenses1);
myWebView.setWebViewClient(new WebViewClient());
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.getSettings().setDomStorageEnabled(true);
myWebView.setOverScrollMode(WebView.OVER_SCROLL_NEVER);
myWebView.loadUrl("https://www.google.com");
myWebView.loadUrl("file:///android_asset/open_source_license.html");
XML:
<WebView
android:id="@+id/web_source_licenses1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="@dimen/text_margin_small"
android:layout_weight="1" />
-----------------------------------------------------------------------------------
----------------------
-----------------------------------------------------------------------------------
----------------------
webview :
<WebView
android:id="@+id/web_source_licenses"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="@dimen/text_margin_small"
android:layout_weight="1" />
<Button
android:id="@+id/btn_source_licenses_close"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginBottom="@dimen/text_margin_very_small"
android:layout_marginEnd="@dimen/text_margin_very_small"
android:text="@string/dialog_close"
android:textColor="@color/colorAccent" />
</LinearLayout>
-----------------------------------------------------------------------------------
-----
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.youtube.com/watch?v=9m_K2Yg7wGQ")));
Log.i("Video", "Video Playing....");
-----------------------------------------------------------------------------------
-----------
Floting bottom snackbar
fab = findViewById(R.id.fab_main);
fab.setOnClickListener(this);
case R.id.fab_main:
Snackbar.make(view, getString(R.string.main_snack_bar),
Snackbar.LENGTH_LONG)
.setAction(getString(R.string.main_snack_bar_action), new
View.OnClickListener() {
@Override
public void onClick(View view) {
}
}).show();
break;
-----------------------------------------------------------------------------------
-----------------------------
private InterstitialAd mInterstitialAd;
//Admob Interstitial Ad
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
mInterstitialAd.loadAd(new AdRequest.Builder().build());
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
mInterstitialAd.show();
}
});
<com.google.android.gms.ads.AdView
android:id="@id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="false"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-8102733205952586/4303866194"
xmlns:ads="http://schemas.android.com/apk/res-auto" />
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-8176005511052186~3015171614"/>
<<<====use this
or
<manifest>
<application>
<meta-data
android:name="com.google.android.gms.ads.AD_MANAGER_APP"
android:value="true"/>
</application>
</manifest>
.addTestDevice("95793537B99A9216EBEB2D783ADBF818")//smasung
.addTestDevice("FE630662306E4D66BF19844EF029DBA2")//mi
-----------------------------------------------------------------------------------
--------------
multiple layout under scrolll view also c=scroll all layout in one page
<ScrollView .....>
<LinearLayout .....>
</LinearLayout>
</ScrollView>
-----------------------------------------------------------------------------------
-----------------
=======SHARE WITH=======
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String shareBody = "Here is the share content body";//url or
content
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Subject Here");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,
shareBody);
startActivity(Intent.createChooser(sharingIntent, "Share via"));
-----------------------------------------------------------------------------------
----------
========================================NOtification==============================
app:app name
implementation 'com.google.firebase:firebase-core:16.0.1'
apply plugin: 'com.google.gms.google-services'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
classpath
classpath 'com.google.gms:google-services:4.0.1'
-----------------------------------------------------------------------------------
---------------------
Anim/file.xml
java :
Animation animation = AnimationUtils.loadAnimation(this,
R.anim.anim_about_card_show);
RelativeLayout relativeLayout = findViewById(R.id.rl);//layout name with id
relativeLayout.startAnimation(animation);
-----------------------------------------------------------------------------------
-----------------------------------------------------
ActionBar actionBar = getSupportActionBar();
if(actionBar!=null)
{
actionBar.setTitle("New Activity");
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
}
}