Você está na página 1de 7

-----------------------------------------------------------------------------------

----------------------
implementation 'com.android.support:support-v4:28.0.0' ///must add this if show
error
-----------------------------------------------------------------------------------
----------------------

if there is show any about the lintjoint


android {

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->

Intent intent = new Intent(view or this.getContext(),


ScrollingActivity.class);
this.startActivity(intent);

another Method
Intent intent = new Intent(Main2Activity.this,
ScrollingActivity.class);
startActivity(intent);

another Method //contructer error show

Intent myIntent = new Intent(MyFragment.this.getActivity(),


MyClass.class);
startActivity(myIntent);

//uri

Intent intent = new Intent(android.content.Intent.ACTION_VIEW);

intent.setData(Uri.parse("https://play.google.com/store/apps/details?
id=com.google.android.youtube"));

startActivity(intent);

////URI

Intent intent = new Intent(android.content.Intent.ACTION_VIEW);

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();

-----------------------------------------------------------------------------------
----------------------

Webview(This open the link in the Same app)

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");

if need to open offline page like "open_source_license.html"

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 :

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">

<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>

-----------------------------------------------------------------------------------
-----

Ad format Sample ad unit ID


Banner ca-app-pub-3940256099942544/6300978111
Interstitial ca-app-pub-3940256099942544/1033173712
Interstitial Video ca-app-pub-3940256099942544/8691691433
Rewarded Video ca-app-pub-3940256099942544/5224354917
Native Advanced ca-app-pub-3940256099942544/2247696110
Native Advanced Video ca-app-pub-3940256099942544/1044960115
-----------------------------------------------------------------------------------
---------

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();
}
});

Ads at Top of the page

<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" />

must add ===>>>

<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 .....>

.............Your All other Layouts .................

</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

<?xml version="1.0" encoding="utf-8"?>


<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:duration="600"
android:fromAlpha="0"
android:toAlpha="1" />
<translate
android:duration="600"
android:fromXDelta="0"
android:fromYDelta="3%"
android:toXDelta="0"
android:toYDelta="0" />
</set>

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);

}
}

public boolean onSupportNavigateUp(){


onBackPressed();
return true;
}

Você também pode gostar