I am using material theme in my app. As specified on the material website here, the app bar uses ColorPrimary in the light theme and ColorSurface in the dark theme. I would like to change the color of the app bar in the dark theme. I can obviously do this by changing the ColorSurface attribute only in the dark theme, but then it affects other components that use this attribute too like Dialogs, TimePickers etc. Is there any way I can only change the color of the app bar in the dark theme?

I'm trying to use .setProgress() on a NotificationBuilder but it seems the pogressBar won't appear if I use MediaStyle:

NotificationCompat.Builder builder = new NotificationCompat.Builder(this,CHANNEL);

builder
  .setSmallIcon(R.drawable.logo)
  // more configuration
  .setStyle(new android.support.v4.media.app.NotificationCompat.MediaStyle()
               .setShowActionsInCompactView(1)
               // more config
               .setMediaSession(mediaSession.getSessionToken()))

if(isBuffering){
  builder.setProgres(0,0, true);
}

If I remove the .setStyle the progress bar appears as supposed but with MediaStyle it won't.

Does anyone know if there is a way to make both compatible?

Thanks

I'd need some help with an Android App here: Basically I'm trying to send HTTPS requests to a Server developed in Node.js. This server is using self-signed certificate. Now I know Android needs AsyncTask in order to send HTTPS requests, so I managed to implement as below:

public class RequestSender extends AsyncTask<String, Void, String> {
    public static final String REQUEST_METHOD = "GET";
    public static final int READ_TIMEOUT = 15000;
    public static final int CONNECTION_TIMEOUT = 15000;

    @Override
    protected String doInBackground(String... params){
        String stringUrl = params[0];
        String result = "RES";
        String inputLine;
        try {
            //Create a URL object holding our url
            URL myUrl = new URL(stringUrl);

            //Create a connection
            HttpsURLConnection connection =(HttpsURLConnection) myUrl.openConnection();

            //Set methods and timeouts
            connection.setHostnameVerifier(new AllowAllHostnameVerifier());
            connection.setRequestMethod(REQUEST_METHOD);
            connection.setReadTimeout(READ_TIMEOUT);
            connection.setConnectTimeout(CONNECTION_TIMEOUT);

            //Connect to our url
            connection.connect();

            //Create a new InputStreamReader
            InputStreamReader streamReader = new InputStreamReader(connection.getInputStream());

            //Create a new buffered reader and String Builder
            BufferedReader reader = new BufferedReader(streamReader);
            StringBuilder stringBuilder = new StringBuilder();

            //Check if the line we are reading is not null
            while((inputLine = reader.readLine()) != null){
                stringBuilder.append(inputLine);
            }

            //Close our InputStream and Buffered reader
            reader.close();
            streamReader.close();

            //Set our result equal to our stringBuilder
            result = stringBuilder.toString();
            Log.d("REQ", "Result received: " + result);
        }
        catch(IOException e){
            e.printStackTrace();
            result = "";
            Log.e("REQ", "REQ Exception: " + e.getMessage());
        }
        return result;
    }
    protected void onPostExecute(String result){
        super.onPostExecute(result);
    }

In order to test it, this is what I do in MainActivity:

RequestSender rSender = new RequestSender();
        rSender.execute(CommandSender.AUTH);
        try {
            String res = rSender.get();
            if(res != null)
                Toast.makeText(this, "Response NOT NULL: " + res, Toast.LENGTH_LONG).show();
            else
                Toast.makeText(this, "Response: NULL!", Toast.LENGTH_LONG).show();
        }
        catch(InterruptedException | ExecutionException ecc){
            ecc.printStackTrace();
        }

Now, if I use previous AsyncTask to send an HTTPS request to https://www.google.com I get Google's html code, which is good. That means my AsyncTask works right?

Issue is, it doesn't work if I send HTTPS request to my Node.js Server, which is online and running. I thought self-signed certificate it's using may be the issue, so I added this:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true" />
    <domain-config>
        <domain includeSubdomains="true">example.com</domain>
        <trust-anchors>
            <certificates src="@raw/cert"/>
        </trust-anchors>
    </domain-config>
</network-security-config>

to res/xml/network_security_config.xml and Certificate used in Server in

res/raw/cert.pem

After all this, I still get empty response. Toast shown in MainActivity only prints: Response NOT NULL!:

What do I have to do in order to make things work here?

Thanks

I have created an book app in which I have to implement banner ad,so when I was putting implementation 'com.google.android.gms:play-services-ads:18.1.1',then an error telling Attribute merger failed came,so I added android.useAndroidX=true and android.enableJetifier=true ,and problem was solved,but all the previous activity file had problem ,so I migrated to android and everything is fine,but when I am testing it on USB Debug phone ,then Activity 1 is opening (total activity:3,1 for icon launcher,2 content list and 3 of content)

Logcat is like this;

     08/20 20:55:42:     Launching app
        $ adb install-multiple -r -t       C:\Users\DELL\AndroidStudioProjects\Stories\app\build\intermediates\resources\instant-run\debug\resources-debug.apk
       C:\Users\DELL\AndroidStudioProjects\Stories\app\build\intermediates\split-apk\debug\dep\dependencies.apk 
   C:\Users\DELL\AndroidStudioProjects\Stories\app\build\intermediates\split-apk\debug\slices\slice_1.apk   
  C:\Users\DELL\AndroidStudioProjects\Stories\app\build\intermediates\split-apk\debug\slices\slice_0.apk     
  C:\Users\DELL\AndroidStudioProjects\Stories\app\build\intermediates\split-apk\debug\slices\slice_2.apk 
  C:\Users\DELL\AndroidStudioProjects\Stories\app\build\intermediates\split-apk\debug\slices\slice_3.apk 
  C:\Users\DELL\AndroidStudioProjects\Stories\app\build\intermediates\split-apk\debug\slices\slice_4.apk 
  C

    :\Users\DELL\AndroidStudioProjects\Stories\app\build\intermediates\split-apk\debug\slices\slice_6.apk
      C:\Users\DELL\AndroidStudioProjects\Stories\app\build\intermediates\split-apk\debug\slices\slice_5.apk
      C:\Users\DELL\AndroidStudioProjects\Stories\app\build\intermediates\split-apk\debug\slices\slice_9.apk   
      C:\Users\DELL\AndroidStudioProjects\Stories\app\build\intermediates\split-apk\debug\slices\slice_8.apk 
      C:\Users\DELL\AndroidStudioProjects\Stories\app\build\intermediates\split-apk\debug\slices\slice_7.apk
     C:\Users\DELL\AndroidStudioProjects\Stories\app\build\intermediates\instant-run-apk\debug\app-debug.apk 
     Split APKs installed in 21 s 798 ms
     $ adb shell am start  
    -n "com.example.stories/com.example.stories.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
     Client not ready yet..Waiting for process to come online
     Connected to process 14000 on device samsung-sm_j600g-5200701fbc2465f9
     Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
     W/example.storie: JIT profile information will not be recorded: profile file does not exits.
     I/chatty: uid=10559(com.example.stories) identical 10 lines
     W/example.storie: JIT profile information will not be recorded: profile file does not exits.
     I/InstantRun: starting instant run server: is main process
     I/DecorView: mWindow.mActivityCurrentConfig is null.
     I/DecorView: createDecorCaptionView >> DecorView@15ef02c[], isFloating: false, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: true
     W/example.storie: Unsupported class loader
     W/example.storie: Skipping duplicate class check due to unsupported classloader
     I/DynamiteModule: Considering local module   
     com.google.android.gms.ads.dynamite:0 and remote module  
     com.google.android.gms.ads.dynamite:20300
        Selected remote version of com.google.android.gms.ads.dynamite, version >= 20300
     V/DynamiteModule: Dynamite loader version 

    >= 2, using loadModule2NoCrashUtils
     I/DynamiteModule: Considering local module com.google.android.gms.measurement.dynamite:7 and remote module com.google.android.gms.measurement.dynamite:9
        Selected remote version of com.google.android.gms.measurement.dynamite, version >= 9
    V/DynamiteModule: Dynamite loader version >= 2, using loadModule2NoCrashUtils
    W/example.storie: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
    W/example.storie: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
    W/example.storie: Unsupported class loader
    W/example.storie: Skipping duplicate class check due to unsupported classloader
    W/example.storie: Unsupported class loader
    W/example.storie: Skipping duplicate class check due to unsupported classloader
    D/OpenGLRenderer: Skia GL Pipeline
    D/EmergencyMode: [EmergencyManager] android createPackageContext successful
    D/InputTransport: Input channel constructed: fd=79
    D/ViewRootImpl@15d9606[MainActivity]: setView = DecorView@15ef02c[MainActivity] TM=true MM=false
    D/ViewRootImpl@15d9606[MainActivity]: stopped(true) old=false
    W/Activity: AppLock checkAppLockState locked:false verifying:false pkgName = com.example.stories isInMultiWindowMode:false showWhenLocked:false
    D/ViewRootImpl@15d9606[MainActivity]: Relayout returned: old=[0,0][720,1480] new=[0,0][720,1480] result=0x1 surface={false 0} changed=false
    I/FA-Ads: App measurement is starting up, version: 16251
        To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
    I/DecorView: mWindow.mActivityCurrentConfig is null.
    I/DecorView: createDecorCaptionView >> DecorView@8c1a5bf[], isFloating: false, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: true
    D/AndroidRuntime: Shutting down VM
    E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.example.stories, PID: 14000
        java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.stories/com.example.stories.Main2Activity}: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class android.support.v7.widget.RecyclerView
            at android.app.ActivityThread

.performLaunchActivity(ActivityThread.java:3126)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3269)
            at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
            at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
            at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1960)
            at 

        android.os.Handler.dispatchMessage(Handler.java:106)
                at android

.os.Looper.loop(Looper.java:214)
            at android.app.ActivityThread.main(ActivityThread.java:7081)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
         Caused by: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class android.support.v7.widget.RecyclerView
         Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class android.support.v7.widget.RecyclerView
         Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.RecyclerView" on path: DexPathList[[zip file "/data/app/com.example.stories-GInON3zF9elFx71lxmHm1Q==/base.apk", zip file "/data/app/com.example.stories-GInON3zF9elFx71lxmHm1Q==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.stories-GInON3zF9elFx71lxmHm1Q==/split_lib_resources_apk.apk", zip file "/data/app/com.example.stories-GInON3zF9elFx71lxmHm1Q==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.stories-GInON3zF9elFx71lxmHm1Q==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.stories-GInON3zF9elFx71lxmHm1Q==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.stories-GInON3zF9elFx71lxmHm1Q==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.stories-GInON3zF9elFx71lxmHm1Q==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.stories-GInON3zF9elFx71lxmHm1Q==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.stories-GInON3zF9elFx71lxmHm1Q==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.stories-GInON3zF9elFx71lxmHm1Q==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.stories-GInON3zF9elFx71lxmHm1Q==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.stories-GInON3zF9elFx71lxmHm1Q==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.stories-GInON3zF9elFx71lxmHm1Q==/lib/arm, /system/lib, /vendor/lib]]
            at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
            at android.view.LayoutInflater.createView(LayoutInflater.java:645)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:829)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:902)
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:863)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:554)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:461)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:383)
            at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
            at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
            at com.example.stories.Main2Activity.onCreate(Main2Activity.java:38)
            at android.app.Activity.performCreate(Activity.java:7340)
    E/AndroidRuntime:     at android.app.Activity.performCreate(Activity.java:7331)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1275)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3106)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3269)
            at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
            at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
            at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1960)
            at android.os.Handler.dispatchMessage(Handler.java:106)
            at android.os.Looper.loop(Looper.java:214)
            at android.app.ActivityThread.main(ActivityThread.java:7081)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
            Suppressed: java.io.IOException: No original dex files found for dex location (arm) /

data/app/com.example.stories-GInON3zF9elFx71lxmHm1Q==/split_lib_resources_apk.apk
            at dalvik.system.DexFile.openDexFileNative(Native Method)
            at dalvik.system.DexFile.openDexFile(DexFile.java:354)
            at dalvik.system.DexFile.<init>(DexFile.java:101)
            at dalvik.system.DexFile.<init>(DexFile.java:75)
            at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394)
            at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)
            at dalvik.system.DexPathList.<init>(DexPathList.java:164)
            at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:74)
            at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
            at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
            at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
            at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
            at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)
            at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)
            at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:766)
            at android.app.LoadedApk.getClassLoader(LoadedApk.java:849)
            at android.app.LoadedApk.getResources(LoadedApk.java:1090)
            at android.app.ContextImpl.createAppContext(ContextImpl.java:2563)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6131)
            at android.app.ActivityThread.access$1200(ActivityThread.java:240)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1797)
                    ... 6 more
    I/Process: Sending signal. PID: 14000 SIG: 9
    Application terminated.

MY Second Activity(Main Activity 2 in which hopefully error is coming ,as its not opening)

    package com.example.stories;

    import android.content.Context;

import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;

import java.util.ArrayList;

public class Main2Activity<mRecyclerView> extends AppCompatActivity {

private static final String TAG = "Main2Activity" ;

private AdView mAdView;


private Context mContext;
ArrayList<String> titleArrayList;
private RecyclerView mRecyclerView;


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


    mContext = Main2Activity.this;

    titleArrayList = new ArrayList<String>();
    titleArrayList.add(com.example.stories.Constants.ANDROCLES);
    titleArrayList.add(com.example.stories.Constants.ANT_AND_GRASSHOPPER);
    titleArrayList.add(com.example.stories.Constants.AVARACIOUS_AND_ENVIOUS);
    titleArrayList.add(com.example.stories.Constants.BELLING_THE_CAT);
    titleArrayList.add(com.example.stories.Constants.FOUR_OXEN_AND_LION);
    titleArrayList.add(com.example.stories.Constants.FOX_AND_CAT);
    titleArrayList.add(com.example.stories.Constants.FOX_AND_LION);
    titleArrayList.add(com.example.stories.Constants.FOX_COCK_AND_DOG);
    titleArrayList.add(com.example.stories.Constants.HARE_WITH_MANY_FRIENDS);
    titleArrayList.add(com.example.stories.Constants.HERCULES_AND_THE_WAGGONER);
    titleArrayList.add(com.example.stories.Constants.LION_AND_STATUE);
    titleArrayList.add(com.example.stories.Constants.LION_FOX_AND_BEAST);
    titleArrayList.add(com.example.stories.Constants.MAN_BOY_AND_DONKEY);
    titleArrayList.add(com.example.stories.Constants.MEMOIRS_OF_A_YELLOW_DOG);
    titleArrayList.add(com.example.stories.Constants.THE_ASS_AND_THE_THE_LAPDOG);
    titleArrayList.add(com.example.stories.Constants.THE_ASS_BRAIN);
    titleArrayList.add(com.example.stories.Constants.THE_ASS_IN_THE_LION_SKIN);
    titleArrayList.add(com.example.stories.Constants.THE_BALDMAN_AND_THE_FLY);
    titleArrayList.add(com.example.stories.Constants.THE_BELLY_AND_THE_MEMBERS);
    titleArrayList.add(com.example.stories.Constants.THE_BOASTING_TRAVELLER);
    titleArrayList.add(com.example.stories.Constants.THE_BOY_WHO_CRIED_WOLF);
    titleArrayList.add(com.example.stories.Constants.THE_BUNDLE_OF_STICKS);
    titleArrayList.add(com.example.stories.Constants.THE_CAMEL_AND_THE_BABY);
    titleArrayList.add(com.example.stories.Constants.THE_CAT_MAIDEN);
    titleArrayList.add(com.example.stories.Constants.THE_COCK_AND_THE_PEARL);
    titleArrayList.add(com.example.stories.Constants.THE_COWS_AND_TIGER);
    titleArrayList.add(com.example.stories.Constants.THE_CROW_AND_PITCHER);
    titleArrayList.add(com.example.stories.Constants.THE_DOG_AND_THE_SHADOW);
    titleArrayList.add(com.example.stories.Constants.THE_DOG_AND_THE_WOLF);
    titleArrayList.add(com.example.stories.Constants.THE_DOG_IN_THE_MANGER);
    titleArrayList.add(com.example.stories.Constants.THE_EAGLE_AND_THE_ARROW);
    titleArrayList.add(com.example.stories.Constants.THE_FARMER_AND_THE_WELL);
    titleArrayList.add(com.example.stories.Constants.THE_FISHER);
    titleArrayList.add(com.example.stories.Constants.THE_FISHER_AND_LITTLE_FISH);
    titleArrayList.add(com.example.stories.Constants.THE_FOUR_STUDENTS);
    titleArrayList.add(com.example.stories.Constants.THE_FOX_AND_GOAT);
    titleArrayList.add(com.example.stories.Constants.THE_FOX_THE_CROW);
    titleArrayList.add(com.example.stories.Constants.THE_FOX_AND_THE_MOSQUITOES);
    titleArrayList.add(com.example.stories.Constants.THE_FOX_AND_THE_STORK);
    titleArrayList.add(com.example.stories.Constants.THE_FROG_AND_THE_MASK);
    titleArrayList.add(com.example.stories.Constants.THE_FOX_WITHOUT_A_TAIL);
    titleArrayList.add(com.example.stories.Constants.THE_FROG_AND_THE_OX);
    titleArrayList.add(com.example.stories.Constants.THE_LION_AND_THE_MOUSE);
    titleArrayList.add(com.example.stories.Constants.THE_LABOURER_AND_NIGHTINGALE);
    titleArrayList.add(com.example.stories.Constants.THE_JAY_AND_THE_PEACOCK);
    titleArrayList.add(com.example.stories.Constants.THE_HORSE_HUNTER_AND_THE_STAG);
    titleArrayList.add(com.example.stories.Constants.THE_HART_IN_THE_OX_STALL);
    titleArrayList.add(com.example.stories.Constants.THE_HART_AND_THE_HUNTER);
    titleArrayList.add(com.example.stories.Constants.THE_HARES_AND_THE_FROG);
    titleArrayList.add(com.example.stories.Constants.THE_GOLDEN_EGG);
    titleArrayList.add(com.example.stories.Constants.THE_FROG_DESIRING_KING);
    titleArrayList.add(com.example.stories.Constants.THE_LION_IN_LOVE);
    titleArrayList.add(com.example.stories.Constants.THE_LION_SHARE);
    titleArrayList.add(com.example.stories.Constants.THE_MAN_AND_HIS_TWO_WIVES);
    titleArrayList.add(com.example.stories.Constants.THE_MAN_AND_SATYR);
    titleArrayList.add(com.example.stories.Constants.THE_MAN_AND_THE_CAT);
    titleArrayList.add(com.example.stories.Constants.THE_MAN_AND_THE_SERPENT);
    titleArrayList.add(com.example.stories.Constants.THE_MAN_AND_THE_WOOD);
    titleArrayList.add(com.example.stories.Constants.THE_MAN_AND_THE_WOODGOD);
    titleArrayList.add(com.example.stories.Constants.THE_MIDAS_TOUCH);
    titleArrayList.add(com.example.stories.Constants.THE_MISER_AND_HIS_GOLD);
    titleArrayList.add(com.example.stories.Constants.THE_MILKMAID_AND_HER_PAIL);
    titleArrayList.add(com.example.stories.Constants.THE_MOUNTAINS_IN_LABOUR);
    titleArrayList.add(com.example.stories.Constants.THE_NURSE_AND_THE_WOLF);
    titleArrayList.add(com.example.stories.Constants.THE_OLDMAN_AND_DEATH);
    titleArrayList.add(com.example.stories.Constants.THE_ONE_EYED_DOE);
    titleArrayList.add(com.example.stories.Constants.THE_PEACOCK_AND_JUNO);
    titleArrayList.add(com.example.stories.Constants.THE_SERPENT_AND_THE_FILE);
    titleArrayList.add(com.example.stories.Constants.THE_SICK_LION);
    titleArrayList.add(com.example.stories.Constants.THE_SKYLIGHT_ROOM);
    titleArrayList.add(com.example.stories.Constants.THE_SWALLOWS_AND_THE_BIRDS);
    titleArrayList.add(com.example.stories.Constants.THE_TORTOISE_AND_THE_BIRD);
    titleArrayList.add(com.example.stories.Constants.THE_TRUMPSTER_TAKE_PRISONER);
    titleArrayList.add(com.example.stories.Constants.THE_TWO_CRABS);
    titleArrayList.add(com.example.stories.Constants.THE_TWO_FELLOWS_AND_THE_BEAR);
    titleArrayList.add(com.example.stories.Constants.THE_TWO_POTS);
    titleArrayList.add(com.example.stories.Constants.THE_WIND_AND_THE_SUN);
    titleArrayList.add(com.example.stories.Constants.THE_WOLF_AND_THE_CRANE);
    titleArrayList.add(com.example.stories.Constants.THE_WOLF_AND_THE_KID);
    titleArrayList.add(com.example.stories.Constants.THE_WOLF_AND_THE_LAMB);
    titleArrayList.add(com.example.stories.Constants.THE_WOODMAN_AND_SERPENT);
    titleArrayList.add(com.example.stories.Constants.THE_YOUNG_THIEF_AND_HIS_MOTHER);
    titleArrayList.add(com.example.stories.Constants.TOWN_MOUSE_AND_COUNTRY_MOUSE);
    titleArrayList.add(com.example.stories.Constants.TREE_AND_REED);
    titleArrayList.add(com.example.stories.Constants.WOLF_IN_SHEEP_CLOTHING);
    titleArrayList.add(com.example.stories.Constants.A_COSMPOLITE_IN_A_CAFE);
    titleArrayList.add(com.example.stories.Constants.BREMEN_TOWN_MUSICIANS);
    titleArrayList.add(com.example.stories.Constants.LITTLE_RED_RIDING_HOOD);
    titleArrayList.add(com.example.stories.Constants.THE_STORY_OF_AN_HOUR);
    titleArrayList.add(com.example.stories.Constants.THE_GIFT_OF_MAGI);

    MobileAds.initialize(this, new OnInitializationCompleteListener() {
        @Override
        public void onInitializationComplete(InitializationStatus initializationStatus) {

        }
    });

    mAdView = findViewById(R.id.adView);
    AdRequest adRequest =new  AdRequest.Builder().build();
    mAdView.loadAd(adRequest);



    mRecyclerView = (RecyclerView) findViewById(R.id.title_layout_recyclerView);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));

    com.example.stories.TitleAdapter adapter = new com.example.stories.TitleAdapter(mContext, titleArrayList, new CustomItemClickListener() {
        @Override
        public void onItemClick(View v, int Position) {

            Intent desIntent = new Intent(mContext,DescriptionActivity.class);
            desIntent.putExtra("titles",titleArrayList.get(Position));
            startActivity(desIntent);
            desIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

            Toast.makeText(mContext,"clicked"+titleArrayList.get(Position),Toast.LENGTH_SHORT).show();
        }
    });

    mRecyclerView.setAdapter(adapter);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu,menu);
    return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()){

        case R.id.share_button:
            Intent sharingIntent = new Intent(Intent.ACTION_SEND);
            sharingIntent.setType("text/plain");
            String shareBody ="https://play.google.com/store/apps/details?id=com.example.stories";
            String shareSubject = "Your Subject Here";

            sharingIntent.putExtra(Intent.EXTRA_TEXT,shareBody);
            sharingIntent.putExtra(Intent.EXTRA_SUBJECT,shareSubject);

            startActivity(Intent.createChooser(sharingIntent,"Share Using"));

            break;
    }

    return super.onOptionsItemSelected(item);
}
}

MY MANIFEST FILE.

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

<uses-permission android:name="android.permission.INTERNET"/>




<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="ca-app-pub-3940256099942544~3347511713"/>

    <activity android:name=".Main2Activity" />
    <activity android:name=".MainActivity">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".DescriptionActivity"
              android:parentActivityName=".Main2Activity"/>
</application>
</manifest>

I am developing with Android BLE API.

There are several sample project for this.

But I found that all samples are using Service, BroadcastReceiver for using the API.

Is there any reason doesn't use a simple helper class instead of Service/Receiver?

I am developing an app in which the image of the front camera is shown in real time and when a condition is met an image is captured, I wish that the image that is captured, which is in UIImage format, can be uploaded to a bucket in s3. Someone who can help me please. I enclose fragments of my code.

    extension CameraViewController: AVCaptureVideoDataOutputSampleBufferDelegate, AVCapturePhotoCaptureDelegate {

  func captureOutput(
    _ output: AVCaptureOutput,
    didOutput sampleBuffer: CMSampleBuffer,
    from connection: AVCaptureConnection
    ) {
    guard let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else {
      print("Failed to get image buffer from sample buffer.")
      return
    }
    lastFrame = sampleBuffer
    let visionImage = VisionImage(buffer: sampleBuffer)
    let metadata = VisionImageMetadata()
    let orientation = UIUtilities.imageOrientation(
      fromDevicePosition: isUsingFrontCamera ? .front : .back
    )

    let visionOrientation = UIUtilities.visionImageOrientation(from: orientation)
    metadata.orientation = visionOrientation
    visionImage.metadata = metadata
    let imageWidth = CGFloat(CVPixelBufferGetWidth(imageBuffer))
    let imageHeight = CGFloat(CVPixelBufferGetHeight(imageBuffer))

    //print("\(imageWidth): \(imageHeight)")

    detectFacesOnDevice(in: visionImage, width: imageWidth, height: imageHeight)
    if(foto == false && capturar == true){
// captured Image
        guard let outputImage = getImageFromSampleBuffer(sampleBuffer: sampleBuffer) else {
            return
        }
        print("foto capturada")
        foto = true
        UIImageWriteToSavedPhotosAlbum(outputImage, nil, nil, nil)
    }
  }
}

I have a notification with the following request and category:

    let content = UNMutableNotificationContent()
    content.title = title // a string
    content.body = body // a string
    content.sound = .default
    content.categoryIdentifier = "foo"

    UNNotificationRequest(
        identifier: UUID().uuidString,
        content: content,
        trigger: trigger // trigger scheduled some seconds in the future, repeats: false
    )

    UNNotificationCategory(
        identifier: content.categoryIdentifier,
        actions: actions,
        intentIdentifiers: [],
        options: .customDismissAction
    )

I schedule it some time in the future (x seconds) and it doesn't repeat. I have the following implementation of the will present delegate method:

public func userNotificationCenter(_ center: UNUserNotificationCenter,
                                   willPresent notification: UNNotification,
                                   withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
    if UIApplication.shared.applicationState != .active {
        completionHandler([.alert, .sound])
    }
}

This is to make sure the notification doesn't show up when the app is in the foreground (I have a modal to show if that's the case).

When the app is backgrounded and I make the notification fire, it shows up as a banner. When I open the phone's notification center I can also see it there. When the app is foregrounded I don't see the banner and it doesn't show up in the notification center. Exactly as intended. However, when the app is foregrounded and I schedule a notification, then minimize the app before the notification is delivered, I don't see the banner either, but it does show up in the notification center.

I'm wondering why does the notification get scheduled and delivered, but not shown as a banner? Is there any known bug regarding this? Is there some relevant code I might be missing? Basically I want any notification that's delivered to the notification center to also show as a banner, but it seems that when the app is minimized after scheduling and before delivery the banner doesn't show up.

I'm creating a new application that can connect with multiple devices via BLE. Where third party devices are centrals and my Iphone is CBPeripheralManager. I need to save data from devices on Iphone and be able to determine which data is when this device connect to Iphone next time.

Question is: How to get unique identifier from central which connect to my peripheralManager?

I would like to know what is the following error ?

error net

The connection Url works.

I try :

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

or :

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>yourserver.com</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSTemporaryExceptionMinimumTLSVersion</key>
            <string>TLSv1.1</string>
        </dict>
    </dict>
</dict>

what can I do When I test my app it's works !

thanks

I have trained a custom object detection, using transfer learning based on MobileNetV2. I converted the model to tflite format so that I can run it on my IOS device. However, when I run the model in xcode, I get an error.

2019-08-20 16:11:07.225613+0100 ObjectDetection[5692:1119136] 
Initialized TensorFlow Lite runtime.
2019-08-20 16:11:07.280287+0100 ObjectDetection[5692:1119136] [MC] 
System group container for 
systemgroup.com.apple.configurationprofiles path is 
/var/containers/Shared/SystemGroup/systemgroup.com.apple.configu    
rationprofiles
2019-08-20 16:11:07.282075+0100 ObjectDetection[5692:1119136] [MC] 
Reading from public effective user settings.

**Failed to invoke the interpreter with error: Provided data count 
1080000 must match the required count 602112.
Failed to invoke the interpreter with error: Provided data count 
1080000  must match the required count 602112.**

Could you please help me to understand what compiler iOS(for Objective-c and Swift) and Android(Java and Kotlin) use?

This question already has an answer here:

Is there a way to embed a view as a common header for a TabBar controller?

I'm researching online and I'm surprised to see there is almost no information when I thought this could be a really common task.

I have subclassed UIBarTabController and I can show my views in only a few lines of code, but adding a common header to my views seems too difficult for no reason.

I have tried to embed my tabbarcontroller in another view unsuccessfully as well.

I have 2 different apps, completely separate and I would like to create a third app that combines these 2 apps and, based on the login that is made, directs to one over the other.

Is it possibile? Which is the best way to combines the 2 apps into a single app?

This question has been covered before but I'm just not getting it.

I have three buttons to show a UIPickerView.

button1.addTarget(self, action: #selector(showPicker), for: .touchUpInside)
button2.addTarget(self, action: #selector(showPicker), for: .touchUpInside)
button3.addTarget(self, action: #selector(showPicker), for: .touchUpInside)

Depending on the button clicked, the picker data (modelData) and tag are updated.

@objc func showFilterPicker(sender: UIButton)
    if sender.tag == 238 {
        modelData = someStringArray1
        filterPickerView.reloadAllComponents()
        filterPickerView.tag = 2238
    } else if sender.tag == 239 {
        modelData = someStringArray2
        filterPickerView.reloadAllComponents()
        filterPickerView.tag = 2239
    } else if sender.tag == 240 {
        modelData = someStringArray3
        filterPickerView.reloadAllComponents()
        filterPickerView.tag = 2240
    }
}

To update the button title

func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
    if filterPickerView.tag == 2238 {
        button1.setTitle(modelData[row], for: .normal)
    } else if filterPickerView.tag == 2239 {
        button2.setTitle(modelData[row], for: .normal)
    } else if filterPickerView.tag == 2240 {
        button3.setTitle(modelData[row], for: .normal)
    }
}

However, this does not work.

Any suggestions or a more detailed example of the linked answers would be helpful, thanks.

Simple problem. I made a settingsActivity and made a sharedPrefernecesLIstener. It worked fine so I left it alone to make the rest of my app. I came back to it to finalize some things and found that it stopped working. I looked through some questions on Stack Overflow and read some things but there are no answers. The Log says: W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed. Searching for this doesn't give me an answer because the answer is usually to a specific instance that I haven't been able to appropriate to me for a solution. For example: An Input is Disposed. I'm out of my depth so I am turning to asking the question.

public class SettingsActivity extends AppCompatActivity {
static final String TAG = "SettingsActivity";
public static final String SHARED_PREFS = "sharedPrefs";
public static final String PREF_NETWORK_TYPE = "network_choice";
public static final String WIFI = "WiFi";
public static final String FIRST = "First";
public static final String WIFI_PREFERENCE = "WiFi Enabled";
public static final String NO_PREFERENCE = "First Enabled";
public String sPref = null;
private NetworkCheck networkCheck;
SharedPreferences sharedPrefs;
SharedPreferences.OnSharedPreferenceChangeListener listener;
private boolean prefWifi = false;
private boolean noPreferredNetwork = true;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.settings_activity);
    networkCheck = new NetworkCheck();
    getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.settings, new SettingsFragment())
            .commit();
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    PreferenceManager.setDefaultValues(this, R.xml.root_preferences, false);

    IntentFilter filter = new IntentFilter(CONNECTIVITY_SERVICE);
    this.registerReceiver(networkCheck, filter);

    if (savedInstanceState == null) {
        sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
        sPref = sharedPrefs.getString(PREF_NETWORK_TYPE, "First");
        if (sPref == null) {
            sPref = FIRST;
        }
        switch (sPref) {
            case WIFI:
                prefWifi = true;
                noPreferredNetwork = false;
                break;
            case FIRST:
                prefWifi = false;
                noPreferredNetwork = true;
                break;
            default:
                prefWifi = false;
                noPreferredNetwork = true;
        }
    }
    Log.i(TAG, "onSharedPreferenceChanged: onCreate - " + sPref + " " + prefWifi + " " + noPreferredNetwork);

    listener = (sharedPreferences, key) -> {
        if (key.equals(PREF_NETWORK_TYPE)) {
            Toast.makeText(SettingsActivity.this, "Tell me this works", Toast.LENGTH_LONG).show();
        }
    };
    listener = (sharedPreferences, key) -> {


        if (key.equals(PREF_NETWORK_TYPE)) {
            sPref = sharedPrefs.getString(PREF_NETWORK_TYPE, "First");
            if (sPref == null) {
                sPref = FIRST;
            }
            prefWifi = sPref.equals(WIFI);
            noPreferredNetwork = sPref.equals(FIRST);
            if (prefWifi) {
                sPref = WIFI;
            } else if (noPreferredNetwork) {
                sPref = FIRST;
            }
            networkType();

            Log.i(TAG, "onSharedPreferenceChanged: in listener- " + sPref + " " + prefWifi + " " + noPreferredNetwork);
        }
    };
    networkType();

}


@Override
public void onDestroy() {
    super.onDestroy();
    if (networkCheck != null) {
        this.unregisterReceiver(networkCheck);
    }
}

@Override
public void onResume() {
    super.onResume();
    sharedPrefs.registerOnSharedPreferenceChangeListener(listener);
}

@Override
public void onPause() {
    super.onPause();
    networkType();
    Log.i(TAG, "onSharedPreferenceChanged: onPause- " + sPref + " " + prefWifi + " " + noPreferredNetwork);
    sharedPrefs.unregisterOnSharedPreferenceChangeListener(listener);
}

public void networkType() {
    sharedPrefs = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPrefs.edit();
    editor.putBoolean(WIFI_PREFERENCE, prefWifi);
    editor.putBoolean(NO_PREFERENCE, noPreferredNetwork);
    editor.apply();

    Log.i(TAG, "onSharedPreferenceChanged: networkType- " + " " + "prefWifi: " + prefWifi + " " + "noPreferredNetwork: " + noPreferredNetwork);

}

public static class SettingsFragment extends PreferenceFragmentCompat {

    @Override
    public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
        setPreferencesFromResource(R.xml.root_preferences, rootKey);
    }
}
}

The interesting thing is that List Preference works the next time I open the app but the Listener doesn't work.

Crashlytics hooks itself into the build process with the Fabric run script in a last run script phase.

"${PODS_ROOT}/Fabric/run"

However, I would prefer to configure and launch it during runtime for various reasons. One reason is the fact that the script is expecting the GoogleService-Info.plist in place, however I have slight variations in naming and atm it is not feasible to create new targets. Is there any way to achieve this?

Firebase itself offers a solution for this by providing

FirebaseApp.configure(options: FirebaseController.options(for: AnEnvironment.debug))

According to Apple's APNs docs, as of iOS 13 clients of the http api must send header fields for apns-push-type and apns-priority or the requests will fail. Sure enough, our users who've udpated to the iOS 13 beta aren't getting silent push notifications that we send through AWS/SNS.

AFAICT, there's no way to "inject" these header fields into the request that SNS actually sends. But it seems like Amazon should just be doing this as a matter of course since without it, billions of notifications will soon start to fail.

Anyone know if they have plans to do this soon? Or maybe they're doing it already and I'm missing something?

I display a popup from a function which runs on a button click, in a tableView (FeedTableViewController)

func preset(){
   let popOverVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "PostOptions") as! PostOptionsViewController
   self.addChild(popOverVC)
   popOverVC.view.frame = self.view.frame
   self.tableView.addSubview(popOverVC.view)
   popOverVC.didMove(toParent: self)
 }

PostOptionsViewController is the VC which gets displayed on the tableView. Now when preset() is run, the popOverVC is being displayed on a single-cell of a tableView instead of the whole tableView.

I want to display it on the whole tableView. I followed the answeres here and that's what I did.

But the VC is being displayed on the cell space and when you scroll, the VC goes with the cell. It takes the bounds of the cell.

So I tried to stop the scroll.

func scrollToggle(){
        print("CLCKED")
        if tableView.isScrollEnabled {
            tableView.isScrollEnabled = false
        }else{
            tableView.isScrollEnabled = true
        }
    }

I try to stop the scroll here so it looks like a popup. Now I can't seem to enable is back again from the action of a button in PostOptionsViewController

I try to do it like this from PostOptionsViewController

@objc func test(_ sender : UILabel){
   self.view.removeFromSuperview()
   let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
   let nextViewController = storyBoard.instantiateViewController(withIdentifier: "feed") as! FeedTableViewController
   nextViewController.scrollToggle()
}

But I get "CLCKED" printed in the console and the view gets removed but I can't scroll the tableView anymore

Please help me understand this.

  1. Why CD has created two additional tables prepending 17 and 19 to them? I didn't create them. My own table name is, ZJOBLxxxx
  2. How can I get rid of them?
  3. How to tackle this error,

CoreData: sql: ALTER TABLE Z_17JOBLxxxx RENAME TO Z_19JOBLxxxx [logging] there is already another table or index with this name: Z_19JOBLxxxx in "ALTER TABLE Z_17JOBLxxxx RENAME TO Z_19JOBLxxxx"

enter image description here I want to show menuSupView when i select row

import UIKit
import Firebase

class ListMember: BaseVC, UITableViewDelegate, UITableViewDataSource {
    @IBOutlet var menuSupView: UIView!
// ......

    override func viewDidLoad() {
        super.viewDidLoad()
        menuSupView.isHidden = true
    }

//.......
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let member = arrMember[indexPath.row]
        self.menuSupView.isHidden = false

    }
}

My menuSupView still hidden. Help me plz

The app I'm developing has an issue with NumberFormatter. When trying to get a NSNumber from String on the iOS 13 (while the app is built with iOS SDK 12), the NumberFormatter returns nil.

When the app is compiled with the iOS SDK 13, the problem disappears. Also, no problem when using iOS SDK 12 and running the app on iOS 12.

How can I debug the app compiled with iOS SDK 12 which runs on iOS 13?

When I trying to do so, the Xcode gives an error that I cannot run the app on the newer iOS with the older version of the SDK.

public let currencyFormatter: NumberFormatter = {
    let f = NumberFormatter()
    f.allowsFloats = true
    f.numberStyle = .currency
    f.locale = Locale.autoupdatingCurrent
    f.currencySymbol = ""
    f.maximumFractionDigits = 2
    f.minimumFractionDigits = 2
    return f
}()

Then, using the formatter:

        let price = "0"
        guard let numberPrice = currencyFormatter.number(from: price) else {
            isValid = false
            break
        }

The else statement gets executed, i.e. currencyFormatter returns nil.