• This is default featured slide 1 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

  • This is default featured slide 2 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

  • This is default featured slide 3 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

  • This is default featured slide 4 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

  • This is default featured slide 5 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

print * (star) 1,2,10

public class Test {

   public static void main(String args[]) {
      int [] numbers = {10, 20, 30, 40, 50};

      for(int x : numbers ) {
         System.out.print( x );
         System.out.print(",");
      }
        int a=0;
      for(int i=1;i<=3;i++){
     
     
          for(int j=1;j<=i;j++){
               j= a+ i*j;
              for(int k=1;k<=j;k++){
                System.out.print("* ");
              a = a+i;
              }
           
          }
           System.out.print("\n");
             
      }
   }
}
***********************Out Put*******************************

* 
* * * 
* * * * * * * * * * 
Share:

get current time and different hours , months , year

public static long getTimeMillis(){
        long time= System.currentTimeMillis();
        //long time= System.currentTimeMillis();
        printLog(" Time value in millisecinds "+time);
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        printLog(" Time value in millisecinds "+/*int mSec =*/ calendar.get(Calendar.MILLISECOND));
        return time;
    }

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






import android.content.Context;

import com.handyjp.R;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;


public class DateTimeUtils {

    public static void main(String[] args) {

        DateTimeUtils obj = new DateTimeUtils();
        SimpleDateFormat simpleDateFormat =
                new SimpleDateFormat("dd/M/yyyy hh:mm:ss");

        try {

            Date date1 = simpleDateFormat.parse("10/10/2013 11:30:10");
            Date date2 = simpleDateFormat.parse("13/10/2013 20:35:55");

            obj.printDifference(date1, date2);

        } catch (ParseException e) {
            e.printStackTrace();
        }

    }

    //1 minute = 60 seconds
    //1 hour = 60 x 60 = 3600
    //1 day = 3600 x 24 = 86400
    public void printDifference(Date startDate, Date endDate){

        //milliseconds
        long different = endDate.getTime() - startDate.getTime();

        System.out.println("startDate : " + startDate);
        System.out.println("endDate : "+ endDate);
        System.out.println("different : " + different);

        long secondsInMilli = 1000;
        long minutesInMilli = secondsInMilli * 60;
        long hoursInMilli = minutesInMilli * 60;
        long daysInMilli = hoursInMilli * 24;

        long elapsedDays = different / daysInMilli;
        different = different % daysInMilli;

        long elapsedHours = different / hoursInMilli;
        different = different % hoursInMilli;

        long elapsedMinutes = different / minutesInMilli;
        different = different % minutesInMilli;

        long elapsedSeconds = different / secondsInMilli;

        System.out.printf(
                "%d days, %d hours, %d minutes, %d seconds%n",
                elapsedDays,
                elapsedHours, elapsedMinutes, elapsedSeconds);

    }
    public static String  printDifference(Context context, long startDate){

        String timediff;
        /*Date currentTime = Calendar.getInstance().getTime();

        SimpleDateFormat sdf = new SimpleDateFormat("dd/M/yyyy hh:mm:ss");
        String currentDateandTime = sdf.format(new Date());

        Date endDate = null;
        try {
            endDate = sdf.parse(currentDateandTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        //milliseconds
        long different = endDate.getTime() - startDate.getTime();*/
        long endDate  =getTimeMillis();
        startDate = startDate*1000;
        long different = endDate - startDate;

        System.out.println("startDate : " + startDate);
        System.out.println("endDate : "+ endDate);
        System.out.println("different : " + different);


        long secondsInMilli = 1000;
        long minutesInMilli = secondsInMilli * 60;
        long hoursInMilli = minutesInMilli * 60;
        long daysInMilli = hoursInMilli * 24;
        long monthsInMilli = (long) (daysInMilli * 30.44);//30.44
        long yearsInMilli = (long) (daysInMilli * 365.24);//365.24

        long elapsedYears = different / yearsInMilli;
        different = different % yearsInMilli;

        long elapsedMonths = different / monthsInMilli;
        different = different % monthsInMilli;

        long elapsedDays = different / daysInMilli;
        different = different % daysInMilli;

        long elapsedHours = different / hoursInMilli;
        different = different % hoursInMilli;

        long elapsedMinutes = different / minutesInMilli;
        different = different % minutesInMilli;

        long elapsedSeconds = different / secondsInMilli;

        System.out.printf(
                "%d years,%d months,%d days, %d hours, %d minutes, %d seconds%n",
                elapsedYears,elapsedMonths,elapsedDays,
                elapsedHours, elapsedMinutes, elapsedSeconds);

        if(elapsedYears !=0){
            if(elapsedYears == 1){
                timediff = elapsedYears +" "+context.getResources().getString(R.string.year);
            }else {
                timediff = elapsedYears + " " + context.getResources().getString(R.string.years);
            }
            return String.valueOf(timediff);
        }else if(elapsedMonths != 0){
            if(elapsedMonths ==1){
                timediff = elapsedMonths+" "+context.getResources().getString(R.string.month);
            }else {
                timediff = elapsedMonths + " " + context.getResources().getString(R.string.months);
            }
            return String.valueOf(timediff);
        }else if(elapsedDays != 0){
            if(elapsedDays == 1){
                timediff = elapsedDays+" "+context.getResources().getString(R.string.day);
            }else {
                timediff = elapsedDays + " " + context.getResources().getString(R.string.days);
            }
            return String.valueOf(timediff);
        }else if(elapsedHours != 0){
            if(elapsedHours == 0){
                timediff = elapsedHours+" "+context.getResources().getString(R.string.hour);
            }else {
                timediff = elapsedHours + " " + context.getResources().getString(R.string.hours);
            }
            return String.valueOf(timediff);
        }else if(elapsedMinutes != 0){
            if(elapsedMinutes == 1){
                timediff = elapsedMinutes+" "+context.getResources().getString(R.string.minute);
            }else {
                timediff = elapsedMinutes + " " + context.getResources().getString(R.string.minutes);
            }
            return String.valueOf(timediff);
        }/*else if(elapsedMinutes != 0){

        }*/

        return timediff = elapsedSeconds+" "+context.getResources().getString(R.string.seconds);
    }
}
Share:

process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 1

update your project gradle .

android studio  3.14


*******************************************************************
gradle wrapper .properties  file change :-

distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip



build.gradle  file change :-


dependencies {
classpath 'com.android.tools.build:gradle:3.1.2' classpath 'com.google.gms:google-services:4.0.0'
// NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files}

following this url:

Share:

get sha1 key in release apk Key Hashes


******************************
linux

*******************************

google / fcm
keytool -list -v -keystore "(path wheare keystore)/keystore.jks" -alias <Alias name there> -storepass <password there> -keypass <password there>


facebook live kay
keytool -exportcert -alias easycom -keystore "/(path wheare keystore)/keystore.jks" | openssl sha1 -binary | openssl base64
Share:

gradle\caches\3.3\scripts\4ut6sil9ssn94pl2jxyri0vh2\init\init0a81367d9b026a15ebd85a3a1f50120f\cache.properties (The system cannot find the file specified)

Error:C:\Users\Nagraj\.gradle\caches\3.3\scripts\4ut6sil9ssn94pl2jxyri0vh2\init\init0a81367d9b026a15ebd85a3a1f50120f\cache.properties (The system cannot find the file specified)



  1. Navigate to C:\Users\user\.gradle\caches\2.x\
  2. Copy the folder scripts , scripts-remapped and paste it somewhere safe just in case anything went wrong you will place it back
  3. Delete this folder scripts and scripts-remapped from the directory C:\Users\user\.gradle\caches\2.x\
  4. Sync Project with Gradle Files and you are done.



Share:

swroll



recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
    @Override
    public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
        super.onScrollStateChanged(recyclerView, newState);

       // int lastvisibleitemposition = gaggeredGridLayoutManager.findLastVisibleItemPosition();        int lastvisibleitemposition =9;// gaggeredGridLayoutManager.getChildCount();        int[] firstVisibleItems = gaggeredGridLayoutManager.findFirstVisibleItemPositions(null);
        if (lastvisibleitemposition == homeAdapter.getItemCount() - 1) {

            if (!loading && !isLastPage) {

                loading = true;
                page_no =page_no+1;
                gethomeData();
               // fetchData((++pageCount));                // Increment the pagecount everytime we scroll to fetch data from the next page                // make loading = false once the data is loaded                // call mAdapter.notifyDataSetChanged() to refresh the Adapter and Layout                homeAdapter.notifyDataSetChanged();
                //AdapterStaggreGrid.itemList.clear();            }


        }
    }
});

8888888888888888888888888888888

private SwipeRefreshLayout swipeRefreshLayout;
private int offSet = 0;

swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_layout);
swipeRefreshLayout.setOnRefreshListener(this);

/** * Showing Swipe Refresh animation on activity create * As animation won't start on onCreate, post runnable is used */swipeRefreshLayout.post(new Runnable() {
                            @Override                            public void run() {
                                swipeRefreshLayout.setRefreshing(true);

                                gethomeData();
                            }
                        }
);

@Overridepublic void onRefresh() {
   // page_no =page_no+1;    gethomeData();
}
Share:

map

Marker startMarker = mMap.addMarker(new MarkerOptions()
        .position(new LatLng(locationList.get(0).getLat(), locationList.get(0).getLong()))
        .icon(BitmapDescriptorFactory.fromResource(R.drawable.at_icon_map_start)));



public void captureScreen() {
    Bitmap image = ImageUtil.getViewBitmap(findViewById(R.id.share_content));
    SharePhoto photo = new SharePhoto.Builder()
            .setBitmap(image)
            .build();
    SharePhotoContent content = new SharePhotoContent.Builder()
            .addPhoto(photo)
            .build();

    ShareDialog shareDialog = new ShareDialog((Activity) context);
    shareDialog.show(content);

    finish();
}
****************************************************************************

import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.location.LocationManager;
import android.provider.Settings;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.afrimack.R;

import static com.afrimack.R.drawable.user;

public class TestGPS extends AppCompatActivity {

    private LocationManager manager;
    private boolean isDataRecieved = false, isRecieverRegistered = false,
            isNetDialogShowing = false, isGpsDialogShowing = false;
    private AlertDialog internetDialog, gpsAlertDialog, locationAlertDialog;
    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_gps);

        manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    }

    @Override    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
     //   Mint.startSession(MainDrawerActivity.this);
        if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
            ShowGpsDialog();
        }
        else {
            removeGpsDialog();
        }
       // registerReceiver(internetConnectionReciever, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"));        registerReceiver(GpsChangeReceiver, new IntentFilter(LocationManager.PROVIDERS_CHANGED_ACTION));
        isRecieverRegistered = true;

        /*if (AndyUtils.isNetworkAvailable(this)                && manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {            if (!isDataRecieved) {                isDataRecieved = true;                checkStatus();            }        }*/        if (manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
            if (!isDataRecieved) {
                isDataRecieved = true;
                //checkStatus();                Log.e("fgcgcgc","hghghhgg");
            }
        }
        /*user = dbHelper.getUser();        if (user != null) {            aQuery.id(ivMenuProfile).progress(R.id.pBar)                    .image(user.getPicture(), imageOptions);
            tvMenuName.setText(user.getFname() + " " + user.getLname());        }*/
    }


    @Override    protected void onStop() {
        // TODO Auto-generated method stub        super.onStop();
       // Mint.closeSession(MainDrawerActivity.this);    }

    private void ShowGpsDialog() {
       // AndyUtils.removeCustomProgressDialog();        isGpsDialogShowing = true;
        AlertDialog.Builder gpsBuilder = new AlertDialog.Builder(
                TestGPS.this);
        gpsBuilder.setCancelable(false);
        gpsBuilder
                .setTitle(getString(R.string.dialog_no_gps))
                .setMessage(getString(R.string.dialog_no_gps_messgae))
                .setPositiveButton(getString(R.string.dialog_enable_gps),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog,
                                                int which) {
                                // continue with delete                                Intent intent = new Intent(
                                        android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                                startActivity(intent);
                                removeGpsDialog();
                            }
                        })

                .setNegativeButton(getString(R.string.dialog_exit),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog,
                                                int which) {
                                // do nothing                                removeGpsDialog();
                                finish();
                            }
                        });
        gpsAlertDialog = gpsBuilder.create();
        gpsAlertDialog.show();
    }

    public void showLocationOffDialog() {

        AlertDialog.Builder gpsBuilder = new AlertDialog.Builder(
                TestGPS.this);
        gpsBuilder.setCancelable(false);
        gpsBuilder
                .setTitle(getString(R.string.dialog_no_location_service_title))
                .setMessage(getString(R.string.dialog_no_location_service))
                .setPositiveButton(
                        getString(R.string.dialog_enable_location_service),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog,
                                                int which) {
                                // continue with delete                                dialog.dismiss();
                                Intent viewIntent = new Intent(
                                        Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                                startActivity(viewIntent);

                            }
                        })

                .setNegativeButton(getString(R.string.dialog_exit),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog,
                                                int which) {
                                // do nothing                                dialog.dismiss();
                                finish();
                            }
                        });
        locationAlertDialog = gpsBuilder.create();
        locationAlertDialog.show();
    }
    private void removeGpsDialog() {
        if (gpsAlertDialog != null && gpsAlertDialog.isShowing()) {
            gpsAlertDialog.dismiss();
            isGpsDialogShowing = false;
            gpsAlertDialog = null;

        }
    }
    public BroadcastReceiver GpsChangeReceiver = new BroadcastReceiver() {
        @Override        public void onReceive(Context context, Intent intent) {

            final LocationManager manager = (LocationManager) context
                    .getSystemService(Context.LOCATION_SERVICE);
            if (manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                // do something                removeGpsDialog();
            } else {
                // do something else                if (isGpsDialogShowing) {
                    return;
                }
                ShowGpsDialog();
            }
        }
    };

    @Override    protected void onDestroy() {

        super.onDestroy();
       // Mint.closeSession(this);        if (isRecieverRegistered) {
           // unregisterReceiver(internetConnectionReciever);            unregisterReceiver(GpsChangeReceiver);
        }

    }
}
Share:
Powered by Blogger.

Recent Posts

Unordered List

  • Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  • Aliquam tincidunt mauris eu risus.
  • Vestibulum auctor dapibus neque.

Theme Support

Need our help to upload or customize this blogger template? Contact me with details about the theme customization you need.