50% Off/-

50% Off/-

Php

50% Off/-

50% Off/-

Web

50% Off/-

50% Off/-

Latest Added Tutorials

We can use FTPClient class in apache commons library to send UTF-8 encoded file names, such as Turkish, chinese, german etc. ftpClient = new FTPClient(); String server ="ftp.server.com"; int port = 21; String user ="test"; String pass ="test"; ftpClient.setControlEncoding("UTF-8");//must be before connect() method ftpClient.connect(server, port); ftpClient.login(user, pass); ftpClient.enterLocalPassiveMode(); ftpClient.setFileType(FTP.BINARY_FILE_TYPE); ftpClient.sendCommand("OPTS UTF8 ON");//we should send this command...Continue Reading
We can use following class to set alarm for multiple day of weeks: import android.app.AlarmManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import java.util.Calendar; public class AlarmStartRadioHelper { private Context mContext; private Class<? extends BroadcastReceiver> mBroadcastReceiverClass; private static int RQS_1 = 1002; private String mActionName; public AlarmStartRadioHelper(Context context, Class<? extends Broa...Continue Reading
Showing admob interstitial ads when splash screen is loaded with a timer can be implemented as follows: package com.codesenior.admob; import android.content.Intent; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; import com.google.android.gms.ads.AdListener; import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.InterstitialAd; import java.util.Timer; import java.util.TimerTask; public class SplashActivity extends AppCompatActivity { private InterstitialAd mInterstitialAd; private Timer...Continue Reading
Android simple GET Request: import android.os.AsyncTask; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class HttpGetRequestTask extends AsyncTask<String, Integer, String> { private RequestResponseHandler requestResponseHandler; public HttpGetRequestTask(RequestResponseHandler requestResponseHandler) { this.requestResponseHandler=requestResponseHandler; } protected String doInBackground(String... urls) {...Continue Reading
Create a notification on Android: String name=""; String message=""; int MID=12345; NotificationManager notificationManager = (NotificationManager) getActivity() .getSystemService(Context.NOTIFICATION_SERVICE); if(notificationManager==null)return; String NOTIFICATION_CHANNEL_ID = "step_counter_channel"; NotificationChannel mChannel; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { int importance = NotificationManager.IMPORTANCE_LOW; mChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, "step_counter_channe...Continue Reading
MainActivity public class MainActivity extends AppCompatActivity implements IabBroadcastReceiver.IabBroadcastListener { private InAppBillingHelper inappbillingHelper; private static final int IN_APP_BILLING_REQUEST_CODE = 10001; private static final String SKU_TEST = "android.test.purchased"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initInappBillingHelper(); btnClick.setOnClickListener(new View.OnClickListener() { @Override pub...Continue Reading
activity_main.xml file <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+...Continue Reading
Fragment re-created on bottom navigation view item selected Solution private void changeFragmentForBottomNavigationView(Bundle savedInstanceState, Fragment fragment) { // Check that the activity is using the layout version with // the fragment_container FrameLayout if (findViewById(R.id.fragment_container) != null) { // However, if we're being restored from a previous state, // then we don't need to do anything and should return or else // we could end up with overlapping fragments. if (savedIns...Continue Reading
import android.content.Context; import android.os.Bundle; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.view.ViewPager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.forex.stockexchange4.R; import com.forex.stockexchange4.models.CalculateSummaryObject; import java.util.ArrayList; import java.util.List; public class CalculateF...Continue Reading
Php Steps 1. Install Socialite: composer require laravel/socialite 2. Add following codes in config/services.php 'google' => [ 'client_id' => env('GOOGLE_CLIENT_ID'), // Your Google Client ID 'client_secret' => env('GOOGLE_CLIENT_SECRET'), // Your Google Client Secret 'redirect' => 'http://www.codesenior.com', ], And add GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET variables in .env file: GOOGLE_CLIENT_ID=692373818685-1s057a8mja62g3i7cmj88v2spt3d8b8e.apps.googleusercontent.com GOOGLE_CLIENT_SECRET=c-4CsKAagTYHVyPKbGVcbAsr...Continue Reading
Error Message: Error:Cause: com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V Solution: Change gradle version as follows: buildscript { repositories { // Gradle 4.1 and higher include support for Google's Maven repo using // the google() method. And you need to include this repo to download // Android plugin 3.0.0 or higher. google() ... } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' } } Problem: Error:Unable to r...Continue Reading
Android GPSTracker.java package com.su.prayertimes.util; import android.Manifest; import android.annotation.SuppressLint; import android.app.AlertDialog; import android.app.Service; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; import android.location.Address; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.os.I...Continue Reading
When using onesignal as notification system in Android application, we should insert following codes in ApplicationManifest.xml file: <meta-data android:name="com.onesignal.NotificationOpened.DEFAULT" android:value="DISABLE" /> After adding this meta-data, Android will disable launcher activity to be opened. Handle notification opened event as follows: public class App extends Application { protected boolean active = true; protected int splashTime = 3000; @Override public void onCreate() { s...Continue Reading
You can use following codes to upload files with extra parameters in Android app: public String uploadFile(String uri, String fileName) throws Exception { String lineEnd = "\r\n"; String twoHyphens = "--"; String boundary = "*****"; int bytesRead, bytesAvailable, bufferSize; byte[] buffer; int maxBufferSize = 1 * 1024 * 1024; FileInputStream fileInputStream = context.openFileInput(fileName); URL url = new URL(uri); // Open a HTTP connection to the URL HttpURLConnection conn = (HttpURLConnection) url.openC...Continue Reading
Question: 1. What is the reason for setting MappedBy in bidirectional many-to-many relationships? 2. When one table has significant amount of records, while other has a few, which side is better to put mappedBy Answer: It's actually a good question, and it helps to understand the concept of an "owning" entity. If you want to prevent both sides (in a bidirectional relationship) from having join tables, a good idea, then you need to have a mappedBy= element on one side. Whether or not there is a join table is controlled by the mappedBy="name" el...Continue Reading

© 2019 All rights reserved. Codesenior.COM