Sunday, September 24, 2017

push notification in firebase using RestAPI


Step 1:
---------------------------

MainActivity.java

package com.edupointbd.amirul.notificationdemourl;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.messaging.FirebaseMessaging;

public class MainActivity extends AppCompatActivity {

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        // If a notification message is tapped, any data accompanying the notification        // message is available in the intent extras. In this project the launcher        // intent is fired when the notification is tapped, so any accompanying data would        // be handled here. If you want a different intent fired, set the click_action        // field of the notification message to the desired intent. The launcher intent        // is used when no click_action is specified.        //        // Handle possible data accompanying notification message.        if (getIntent().getExtras() != null) {
            if (getIntent().getStringExtra("LINK")!=null) {
                Intent i=new Intent(this,AnotherActivity.class);
                i.putExtra("link",getIntent().getStringExtra("LINK"));
                MainActivity.this.startActivity(i);
                finish();
            }}



        subscribeToPushService();

    }

    private void subscribeToPushService() {
        FirebaseMessaging.getInstance().subscribeToTopic("news");

        Log.d("AndroidBash", "Subscribed");
        Toast.makeText(MainActivity.this, "Subscribed", Toast.LENGTH_SHORT).show();

        String token = FirebaseInstanceId.getInstance().getToken();
        try {
            // Log and toast            Log.d("AndroidBash", token);
            Toast.makeText(MainActivity.this, token, Toast.LENGTH_SHORT).show();
        }catch (NullPointerException e){
            e.printStackTrace();

        }




    }

    @Override    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will        // automatically handle clicks on the Home/Up button, so long        // as you specify a parent activity in AndroidManifest.xml.        int id = item.getItemId();

        //noinspection SimplifiableIfStatement        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}



activity_main.xml


<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:id="@+id/activity_main"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:paddingBottom="@dimen/activity_vertical_margin"    android:paddingLeft="@dimen/activity_horizontal_margin"    android:paddingRight="@dimen/activity_horizontal_margin"    android:paddingTop="@dimen/activity_vertical_margin"    tools:context="com.edupointbd.amirul.notificationdemourl.MainActivity">

    <ImageView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginBottom="16dp"        android:layout_gravity="center_horizontal"        android:src="@drawable/ic_stat_ict_hub" />

    <TextView        android:id="@+id/informationTextView"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_gravity="center_horizontal"        android:gravity="center_horizontal"        android:text="@string/app_name" />
</RelativeLayout>


step 2:


AnotherActivity .java

package com.edupointbd.amirul.notificationdemourl;

import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
import android.widget.TextView;
import android.widget.Toast;

public class AnotherActivity extends AppCompatActivity {

    TextView tvT;

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_another);
        WebView webView = (WebView) findViewById(R.id.web);


        Intent i = getIntent();
        String url = i.getStringExtra("link");
        if (!url.startsWith("http://") && !url.startsWith("https://")) {
            url = "http://" + url;
            webView.loadUrl(url);
            Intent ii = new Intent(Intent.ACTION_VIEW);
            ii.setData(Uri.parse(url));
            startActivity(ii);
        }


        Toast.makeText(getApplicationContext(),url,Toast.LENGTH_LONG).show();

    }
}


activity_anothe.xml

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:id="@+id/activity_another"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:paddingBottom="@dimen/activity_vertical_margin"    android:paddingLeft="@dimen/activity_horizontal_margin"    android:paddingRight="@dimen/activity_horizontal_margin"    android:paddingTop="@dimen/activity_vertical_margin"    tools:context="com.edupointbd.amirul.notificationdemourl.AnotherActivity">


    <WebView        android:id="@+id/web"        android:layout_width="match_parent"        android:layout_height="match_parent"        android:layout_centerVertical="true" />
</RelativeLayout>


step 3:
package com.edupointbd.amirul.notificationdemourl;


import android.util.Log;

import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;

/** * Created by Amirul on 24-Sep-17. */
public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {


    private static final String TAG = "MyFirebaseIIDService";

    /**     * Called if InstanceID token is updated. This may occur if the security of     * the previous token had been compromised. Note that this is called when the InstanceID token     * is initially generated so this is where you would retrieve the token.     */    // [START refresh_token]    @Override    public void onTokenRefresh() {
        // Get updated InstanceID token.        String refreshedToken = FirebaseInstanceId.getInstance().getToken();
        Log.d(TAG, "Refreshed token: " + refreshedToken);

        // If you want to send messages to this application instance or        // manage this apps subscriptions on the server side, send the        // Instance ID token to your app server.        sendRegistrationToServer(refreshedToken);
    }
    // [END refresh_token]
    /**     * Persist token to third-party servers.     *     * Modify this method to associate the user's FCM InstanceID token with any server-side account     * maintained by your application.     *     * @param token The new token.     */    private void sendRegistrationToServer(String token) {
        // TODO: Implement this method to send token to your app server.    }
}

step 4:

package com.edupointbd.amirul.notificationdemourl;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.RingtoneManager;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import android.util.Log;

import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

/** * Created by Amirul on 24-Sep-17. */
public class MyFirebaseMessagingService extends FirebaseMessagingService {

    private static final String TAG = "FirebaseMessageService";
    Bitmap bitmap;

    /**     * Called when message is received.     *     * @param remoteMessage Object representing the message received from Firebase Cloud Messaging.     */    @Override    public void onMessageReceived(RemoteMessage remoteMessage) {
        // There are two types of messages data messages and notification messages. Data messages are handled        // here in onMessageReceived whether the app is in the foreground or background. Data messages are the type        // traditionally used with GCM. Notification messages are only received here in onMessageReceived when the app        // is in the foreground. When the app is in the background an automatically generated notification is displayed.        // When the user taps on the notification they are returned to the app. Messages containing both notification        // and data payloads are treated as notification messages. The Firebase console always sends notification        // messages. For more see: https://firebase.google.com/docs/cloud-messaging/concept-options        //        Log.d(TAG, "From: " + remoteMessage.getFrom());

        // Check if message contains a data payload.        if (remoteMessage.getData().size() > 0) {
            Log.d(TAG, "Message data payload: " + remoteMessage.getData());
        }

        // Check if message contains a notification payload.        if (remoteMessage.getNotification() != null) {
            Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
        }

        //The message which i send will have keys named [message, image, AnotherActivity] and corresponding values.        //You can change as per the requirement.
        //message will contain the Push Message        String message = remoteMessage.getData().get("message");
        //imageUri will contain URL of the image to be displayed with Notification        String imageUri = remoteMessage.getData().get("image");
        //If the key AnotherActivity has  value as True then when the user taps on notification, in the app AnotherActivity will be opened.        //If the key AnotherActivity has  value as False then when the user taps on notification, in the app MainActivity will be opened.        String TrueOrFlase = remoteMessage.getData().get("AnotherActivity");

        //To get a Bitmap image from the URL received        bitmap = getBitmapfromUrl(imageUri);

        sendNotification(message, bitmap, TrueOrFlase);

    }


    /**     * Create and show a simple notification containing the received FCM message.     */
    private void sendNotification(String messageBody, Bitmap image, String TrueOrFalse) {
        Intent intent = new Intent(this, MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.putExtra("LINK", messageBody);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
                PendingIntent.FLAG_ONE_SHOT);

        Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                .setLargeIcon(image)/*Notification icon image*/                .setSmallIcon(R.drawable.ic_stat_ict_hub)
                .setContentTitle(messageBody)
                .setStyle(new NotificationCompat.BigPictureStyle()
                        .bigPicture(image))/*Notification with Image*/                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent);

        NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
    }

    /*    *To get a Bitmap image from the URL received    * */    public Bitmap getBitmapfromUrl(String imageUrl) {
        try {
            URL url = new URL(imageUrl);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setDoInput(true);
            connection.connect();
            InputStream input = connection.getInputStream();
            Bitmap bitmap = BitmapFactory.decodeStream(input);
            return bitmap;

        } catch (Exception e) {
            // TODO Auto-generated catch block            e.printStackTrace();
            return null;

        }
    }
}

step 5:

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="com.edupointbd.amirul.notificationdemourl">

    <application        android:allowBackup="true"        android:icon="@mipmap/ic_launcher"        android:label="@string/app_name"        android:supportsRtl="true"        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <service android:name=".MyFirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
        <service android:name=".MyFirebaseInstanceIDService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
        </service>

        <activity android:name=".AnotherActivity"></activity>
    </application>

</manifest>


step 6:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'        classpath 'com.google.gms:google-services:3.0.0'


        // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}



step 7:
apply plugin: 'com.android.application'
android {
    compileSdkVersion 25    buildToolsVersion "25.0.2"    defaultConfig {
        applicationId "com.edupointbd.amirul.notificationdemourl"        minSdkVersion 16        targetSdkVersion 25        versionCode 1        versionName "1.0"        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"    }
    buildTypes {
        release {
            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'    })
    compile 'com.android.support:appcompat-v7:25.3.1'    compile 'com.google.firebase:firebase-core:9.4.0'    compile 'com.google.firebase:firebase-messaging:9.4.0'    compile 'com.google.android.gms:play-services-auth:9.4.0'    testCompile 'junit:junit:4.12'}
apply plugin: 'com.google.gms.google-services'



step 8:


to fixed device
https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIza************adrTY
 
{ "data": {
    "image": "https://ibin.co/2t1lLdpfS06F.png",
    "message": "Firebase Push Message Using API"
    "AnotherActivity": "True"
  },
  "to" : "f25gYF3***********************HLI"
}
all device same message to send
{ "condition": "'news' in topics || 'cats' in topics", "data": { "image": "https://ibin.co/2t1lLdpfS06F.png", "message": "www.edupointbd.com", "AnotherActivity": "True", } }

Friday, September 22, 2017

interstitialAd Show in android || One activity to another activity Lunching

step 1: 

 Add first in your App.gradle file

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'    })
    compile 'com.android.support:appcompat-v7:25.3.1'    compile 'com.google.android.gms:play-services-ads:9.2.0'    testCompile 'junit:junit:4.12'}

step 2: 

MainActivity.java

package com.edupointbd.amirul.notificationdemo;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.TaskStackBuilder;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.NotificationCompat;
import android.util.Log;
import android.view.View;

import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.InterstitialAd;

public class MainActivity extends AppCompatActivity {


    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


    }

    public void notificationBtn(View view){

        NotificationCompat.Builder builder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
                .setSmallIcon(R.drawable.amirul)
                .setContentTitle("ICT HUB")
                .setContentText("how are you");

        Intent resultIntent = new Intent(this, ResultActivity.class);
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
        stackBuilder.addParentStack(ResultActivity.class);
        stackBuilder.addNextIntent(resultIntent);

        PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(
                0, PendingIntent.FLAG_UPDATE_CURRENT );
        builder.setContentIntent(resultPendingIntent);
        NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        mNotificationManager.notify(101, builder.build());

    }

    public void addMod(View view){
        AdManager adManager = new AdManager(this,"ca-app-pub-3940256099942544/1033173712");
        adManager.createAd();
        Intent intent = new Intent(getApplicationContext(),SecondActivity.class);
        startActivity(intent);

    }
}


Activitymain.xml


<?xml version="1.0" encoding="utf-8"?><RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android"   
 xmlns:tools="http://schemas.android.com/tools"    
android:id="@+id/activity_main"   
 android:layout_width="match_parent"  
  android:layout_height="match_parent"    
android:paddingBottom="@dimen/activity_vertical_margin"    
android:paddingLeft="@dimen/activity_horizontal_margin"    
android:paddingRight="@dimen/activity_horizontal_margin"   
 android:paddingTop="@dimen/activity_vertical_margin"    
tools:context="com.edupointbd.amirul.notificationdemo.MainActivity">

 <Button     android:id="@+id/btn1"    
 android:text="do it"    
 android:onClick="notificationBtn"    
 android:layout_width="match_parent"    
 android:layout_height="wrap_content" />
 <Button     android:text="New activity"   
  android:layout_below="@+id/btn1"    
 android:id="@+id/btnadd"     android:onClick="addMod"  
   android:layout_width="match_parent"    
 android:layout_height="wrap_content" />
</RelativeLayout>

step 3:

AdManage.java

package com.edupointbd.amirul.notificationdemo;

import android.app.Activity;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.InterstitialAd;

/** * Created by Amirul on 22-Sep-17. */
public class AdManager {
    private static InterstitialAd interstitialAd;

    private static boolean isInterAdsShowed = false;
    private Activity activity;
    private String AD_UNIT_ID;

    AdManager(Activity activity, String AD_UNIT_ID) {

        this.activity = activity;
        this.AD_UNIT_ID = AD_UNIT_ID;
        createAd();
    }

  void createAd() {
        // Create an ad.        interstitialAd = new InterstitialAd(activity);
        interstitialAd.setAdUnitId(AD_UNIT_ID);

        AdRequest adRequest = new AdRequest.Builder()
                //.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)             
   //.addTestDevice(TEST_DEVICE_ID)                .build();

        // Load the interstitial ad.        interstitialAd.loadAd(adRequest);
    }

    static InterstitialAd getAd() {
        if (interstitialAd != null && interstitialAd.isLoaded() && !isInterAdsShowed) {
            isInterAdsShowed = true;
            return interstitialAd;
        } else return null;
    }
}


step 4:

SecondActivity.java

package com.edupointbd.amirul.notificationdemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.google.android.gms.ads.InterstitialAd;

public class SecondActivity extends AppCompatActivity {

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        InterstitialAd ad = AdManager.getAd();
        if (ad != null) {
            ad.show();

        }else {
            Log.d("Add","empty");
        }
    }
}


activity_secound.xml

<?xml version="1.0" encoding="utf-8"?><RelativeLayout
 xmlns:android="http://schemas.android.com/apk/res/android"   
 xmlns:tools="http://schemas.android.com/tools"   
 android:id="@+id/activity_second"    android:layout_width="match_parent"  
 android:layout_height="match_parent"   
 android:paddingBottom="@dimen/activity_vertical_margin"    
android:paddingLeft="@dimen/activity_horizontal_margin"   
 android:paddingRight="@dimen/activity_horizontal_margin" 
  android:paddingTop="@dimen/activity_vertical_margin"   
 tools:context="com.edupointbd.amirul.notificationdemo.SecondActivity">
    <Button        android:id="@+id/it"     

   android:text="welcome to you"     
   android:layout_width="match_parent"    
    android:layout_height="wrap_content" />
</RelativeLayout>


Thursday, September 21, 2017

oops-concepts-in-java-interview-questions

(1) What is OOPS in Java?
The object-oriented programming system(oops) is a methodology which provides us certain concepts. By using these concepts we can easily design our application with related to the real-world entity.

(2) What are some core concepts of OOPS in java?
There are some different core concepts of oops and these are
• Class
• Object
• Polymorphism
• Inheritance
• Encapsulation
• Aggreagation
• Composition
• Association
• Abstraction

What is class in Java?
A class is a blueprint or template of an object in java which can have field, constructors, methods, objects. The class is a logical entity.

What is an object?
An object is an instance of a class and it is dynamic memory allocation of class. An entity that has properties(state) and behavior is known as object e.g fan, pen, laptop, mobile, etc.

What is are the characteristics of the object?
1) State

Instance variables(i.e data member) is known as object state.

2) Behavior

An instance method is known as object behavior.

3) Identity

An object identity is implemented via unique ID. This unique id is internally used by JVM to identify each object uniquely. Identity is the hashcode of an object and it is a 32-bit integer number.

What is Polymorphism?
In simple word, Polymorphism means one name many forms e.g A child in home behave(work) like a son and in school behave(work) like a student so there is one name child but producing different-different behaviors in different-different circumstances.

Types of Polymorphism?
There are 2 types of polymorphism.
• Compile-time or Static polymorphism.
• Run-time or Dynamic polymorphism.

What is Method Overloading?
Method overloading is also known as compile-time polymorphism in java. Method overloading, whenever we have more than one method with the same name but the different number of parameters or the different type of parameter in the same class is known as method overloading.

What is Method Overriding?
Method overriding is also known as runtime polymorphism in java. To achieve method overriding there must be a parent-child relationship(inheritance) i.e Is-a relationship. Whenever we have same name method in both parent and child class with the same number of parameters and types is known as method overriding.

What is inheritance?
Inheritance means re-usability and it is basically used to achieve runtime polymorphism or dynamic binding in java. In this concept, there is parent-child relationship i.e Is-a relationship and child can inherit or reuse all the methods and properties of its parent class by using "extends" keyword.

Types of Inheritance?
1. Single Level Inheritance
2. Multilevel Inheritance
3. Multiple Inheritance
4. Heirarchical Inheritance
5. Hybrid Inheritance

Does Java Support Multiple Inheritance?
Java does not support multiple inheritance through the class but it is possible through the interface.

What is Abstraction in Java?
Abstraction is also an object-oriented feature of java which shows only functionality or useful data to the user and hides internal working or internal implementation details to the user.

for example: Suppose you driving a car and you using all the functions of a car but you don't know how internally this function works.



How to Achieve Abstraction in Java?
There are two ways you can achieve abstraction and these are


1. Abstract class(0 to 100%)
2. Interface(100%)
What is Encapsulation?
Encapsulation is a process of wrapping or combining the data and function into a single unit. You can use access modifiers for variables so other classes may not access it directly but it can be accessed only through public methods of the class. By using private variables you can create fully encapsulated class.

Difference Between Abstraction and Encapsulation?
Abstraction is a process which shows the functionality to the user and hides its implementation details whereas Encapsulation provides a barrier to access of data and methods.

What is Aggregation?
An aggregation is a special form of association. When one object contains another object is called aggregation in java. An aggregation represents HAS-A relationship.

For example:

class Student
{
int rollno;
String name;
Address address;//contains another object like street, city, country.

What is composition?
Composition is a special form of aggregation. If the object contains another object and contained object cannot exist without container object is known as composition.

For example:

Bus has an engine but without a bus engine cannot exist.

What is Association?
Association is a relationship between two objects. It define association between object such as one-to-one, one-to-many, many-to-one, many-to-many.

What is Static Binding?
Static binding is also known as early binding and it resolved at compile-time. Method overloading is the best example of static binding.

What is Dynamic Binding?
Dynaic binding is also known as late binding and it resolved at run-time. Method overriding is the best example of dynamic binding.

Here we have learned 4 major principles of object-oriented programming such as polymorphism, inheritance , encapsulation, abstraction, etc.

Thursday, September 14, 2017

notification

say something in android

Saturday, August 19, 2017

marquee text use in android

marquee tag ব্যবহার করা যাবে।


<TextView    android:text="some instruction"    android:id="@+id/txtTicker"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:layout_centerHorizontal="true"    android:layout_gravity="center_horizontal"    android:ellipsize="marquee"    android:focusable="true"    android:focusableInTouchMode="true"    android:freezesText="true"    android:gravity="center_horizontal"    android:marqueeRepeatLimit="marquee_forever"    android:paddingLeft="5dip"    android:paddingRight="5dip"    android:scrollHorizontally="true"    android:shadowColor="#FF0000"    android:shadowDx="1.5"    android:shadowDy="1.3"    android:shadowRadius="1.6"    android:singleLine="true"    android:textColor="@android:color/white"    android:textSize="20sp"    android:textStyle="bold" >
</TextView>

Monday, August 14, 2017

How to add git picture in android project- কিভাবে আনিমেটেড ছবি এন্ডইয়েড প্রজেক্টে দেখানো যাই।

প্রথমে gradle(Module :app)

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'    })
    compile 'com.android.support:appcompat-v7:25.3.1'    compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.4' (******)    testCompile 'junit:junit:4.12'}


উপরে * চিহ্নিত লাইনটি যুক্ত করে দিতে হবে। 

তার পর Sync করলে কিছুক্ষন আপেক্ষা করার পর সব রেডি হয়ে যাবে আর কিছু করা লাগবে না।

আপনার xml ফাইল গিয়ে নিচের মত করে gif file টি drawable ফোল্ডারে রেখে imageView করার মত করে call করলে হবে।

<pl.droidsonroids.gif.GifTextView    android:layout_marginTop="2dp"    android:padding="25dp"    android:layout_marginRight="22dp"    android:layout_marginLeft="22dp"    android:layout_marginBottom="15dp"    android:layout_width="wrap_content"    android:layout_height="100dp"    android:background="@drawable/image"    />

এখানে image.gif নামে ফাইল টি drawable ফোল্ডারে রাখা আছে। 

আজ এই পর্যন্ত-
নতুন কোন টপিক্স নিয়ে আবার হাজির হব। সে পর্যন্ত ভালথাকবেন।