• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Unable to refresh BrowseFragment listrow successfully after making change to json data

Hi,

I am building an android tv app with a BrowseFragment that displays a listrow with data pulled from a php created JSON file (data is got from MySQL table). There is a check that is run to see if any changes to the database and after which when the change is detected, the BrowseFragment is to be refreshed reloading the json data.

I attempted the refresh from both the BrowseFragments parent activity and the fragment itself (I attempted to use the clear() and addall() functions of ArrayObjectAdapter) and there would just be a flash/blinking but the information would not be refreshed. The only way I have been able to update the listrow has been to restart the app.

How can I successfully update/refresh the BrowseFragment list row?

I have placed the code for my MainFragment and BrowseFragment

Java:
public class MainFragment extends BrowseSupportFragment
        implements LoaderManager.LoaderCallbacks<LinkedHashMap<String, List<Video>>>{

    private static final int BACKGROUND_UPDATE_DELAY = 300;

    private static final String TAG = MainFragment.class.getSimpleName();

    static final int GRID_ITEM_WIDTH = 300;
    private static final int GRID_ITEM_HEIGHT = 200;
    private final Handler mHandler = new Handler();
    //private ArrayObjectAdapter mRowsAdapter;
    private CustumArrayObjectAdapter mRowsAdapter;
    private Drawable mDefaultBackground;
    private DisplayMetrics mMetrics;
    private Runnable mBackgroundTask;
    private Uri mBackgroundURI;
    private BackgroundManager mBackgroundManager;
    private CustomListRow mGridItemListRow;
    private LoaderManager mLoaderManager;

    ArrayList<Video> mItems = null;
    private ArrayList<CustomListRow> mVideoListRowArray;
    private static final int VIDEO_ITEM_LOADER_ID = 1;

/**
    // Init
    private Handler handler = new Handler();
    private Runnable runnable = new Runnable() {
        @Override
        public void run() {
            updateChannels();
            handler.postDelayed(this, 10000);
        }
    };

**/






    @Override
    public void onActivityCreated(Bundle savedInstanceState) {


        // Final initialization, modifying UI elements.
        super.onActivityCreated(savedInstanceState);

        // Prepare the manager that maintains the same background image between activities.
        prepareBackgroundManager();

        setupUIElements();

        loadRows();
        setRows();

        mBackgroundURI = Uri.parse("http://192.168.0.4/test/images/bkground/background1.jpg");

;
        mLoaderManager = LoaderManager.getInstance(this);
        mLoaderManager.initLoader(VIDEO_ITEM_LOADER_ID, null, this);

        setupEventListeners();
        prepareEntranceTransition();

        updateRecommendations();


        /**
        //Start
        handler.postDelayed(runnable, 10000);

         **/


    }

    @Override
    public void onDestroy() {
        mHandler.removeCallbacks(mBackgroundTask);
        mBackgroundManager = null;
        super.onDestroy();
    }

    /**

    public void updateChannels(){

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(ApiInterface.JSONURL)
                .addConverterFactory(ScalarsConverterFactory.create())
                .build();

        ApiInterface api = retrofit.create(ApiInterface.class);

        Call<String> call = api.getString();

        call.enqueue(new Callback<String>() {
            @Override
            public void onResponse(Call<String> call, Response<String> response) {
                Log.i("Responsestring", response.body().toString());
                //Toast.makeText()
                if (response.isSuccessful()) {
                    if (response.body() != null) {
                        Log.i("onSuccess", response.body().toString());

                        String jsonresponse = response.body().toString();
                        chkResponse(jsonresponse);

                    } else {
                        Log.i("onEmptyResponse", "Returned empty response");//Toast.makeText(getContext(),"Nothing returned",Toast.LENGTH_LONG).show();
                    }
                }
            }

            @Override
            public void onFailure(Call<String> call, Throwable t) {

            }
        });

    }

    private void chkResponse(String response){

        try {
            //getting the whole json object from the response
            JSONObject obj = new JSONObject(response);
            if(obj.optString("update").equals("true"))
            {

                try {


     getLoaderManager().restartLoader(0, null, this);


     mVideoListRowArray = null;
     mItems = null;



     mLoaderManager.restartLoader(0, null,  this);

     mLoaderManager = LoaderManager.getInstance(this);
     mLoaderManager.initLoader(VIDEO_ITEM_LOADER_ID, null, this);

     setupUIElements();
     loadRows();
     setRows();

     mRowsAdapter.clear();
     mRowsAdapter.addAll(0, mVideoListRowArray);
     mRowsAdapter.replaceAll(0, mVideoListRowArray);


     //Intent intent = new Intent(getActivity(), MainActivity.class);
     //intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
     //startActivity(intent);

                } catch (Exception e)
                {
                    Toast.makeText(this, "Error Refreshing Channel Rows.", Toast.LENGTH_SHORT).show();

                }

            }

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

    }

     **/






    /**
     @Override
     public void onResume() {

     mCategoryRowAdapter.clear();

     mLoaderManager = LoaderManager.getInstance(this);
     mLoaderManager.initLoader(CATEGORY_LOADER, null, this);


     mCategoryRowAdapter = new ArrayObjectAdapter(new ListRowPresenter());
     setAdapter(mCategoryRowAdapter);
     super.onResume();
     }
     **/

    @Override
    public void onStop() {
        mBackgroundManager.release();
        super.onStop();
    }

    private void prepareBackgroundManager() {
        mBackgroundManager = BackgroundManager.getInstance(getActivity());
        mBackgroundManager.attach(getActivity().getWindow());
        mDefaultBackground = getResources().getDrawable(R.drawable.backgroundtv, null);
        mBackgroundTask = new UpdateBackgroundTask();
        mMetrics = new DisplayMetrics();
        getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
    }

    private void setupUIElements() {
        setBadgeDrawable(
                getActivity().getResources().getDrawable(R.drawable.twende, null));
        setTitle(getString(R.string.browse_title)); // Badge, when set, takes precedent over title
        setHeadersState(HEADERS_ENABLED);
        setHeadersTransitionOnBackEnabled(true);

        // Set fastLane (or headers) background color
        setBrandColor(ContextCompat.getColor(getActivity(), R.color.fastlane_background));

        // Set search icon color.
        setSearchAffordanceColor(ContextCompat.getColor(getActivity(), R.color.search_opaque));

        setHeaderPresenterSelector(new PresenterSelector() {
            @Override
            public Presenter getPresenter(Object o) {
                return new IconHeaderItemPresenter();
            }
        });
    }

    private void setupEventListeners() {
        setOnSearchClickedListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                //Intent intent = new Intent(getActivity(), SearchActivity.class);
                //startActivity(intent);
            }
        });

        setOnItemViewClickedListener(new ItemViewClickedListener());
        setOnItemViewSelectedListener(new ItemViewSelectedListener());
    }

    private void updateBackground(String uri) {
        int width = mMetrics.widthPixels;
        int height = mMetrics.heightPixels;

        RequestOptions options = new RequestOptions()
                .centerCrop()
                .error(mDefaultBackground);

        Glide.with(getActivity())
                .asBitmap()
                .load(uri)
                .apply(options)
                .into(new SimpleTarget<Bitmap>(width, height) {
                    @Override
                    public void onResourceReady(
                            Bitmap resource,
                            Transition<? super Bitmap> transition) {
                        mBackgroundManager.setBitmap(resource);
                    }
                });
    }

    private void startBackgroundTimer() {
        mHandler.removeCallbacks(mBackgroundTask);
        mHandler.postDelayed(mBackgroundTask, BACKGROUND_UPDATE_DELAY);
    }

    private void updateRecommendations() {
        Intent recommendationIntent = new Intent(getActivity(), UpdateRecommendationsService.class);
        getActivity().startService(recommendationIntent);
    }



    private class UpdateBackgroundTask implements Runnable {

        @Override
        public void run() {
            if (mBackgroundURI != null) {
                updateBackground(mBackgroundURI.toString());
            }
        }
    }

    private final class ItemViewClickedListener implements OnItemViewClickedListener {
        @Override
        public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
                                  RowPresenter.ViewHolder rowViewHolder, Row row) {

            if (item instanceof Video) {
                Video video = (Video) item;
                Intent intent = new Intent(getActivity(), VideoDetailsActivity.class);
                intent.putExtra(VideoDetailsActivity.VIDEO, video);

                Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
                        getActivity(),
                        ((ImageCardView) itemViewHolder.view).getMainImageView(),
                        VideoDetailsActivity.SHARED_ELEMENT_NAME).toBundle();
                getActivity().startActivity(intent, bundle);
            } else if (item instanceof String) {
                if (((String) item).contains(getString(R.string.guidedstep_first_title))) {
                    Intent intent = new Intent(getActivity(), GuidedStepActivity.class);
                    Bundle bundle =
                            ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity())
                                    .toBundle();
                    startActivity(intent, bundle);
                } else if (((String) item).contains(getString(R.string.error_fragment))) {
                    BrowseErrorFragment errorFragment = new BrowseErrorFragment();
                    getFragmentManager().beginTransaction().replace(R.id.movie_frame, errorFragment)
                            .addToBackStack(null).commit();
                } else if(((String) item).contains(getString(R.string.personal_settings))) {
                    Intent intent = new Intent(getActivity(), SettingsActivity.class);
                    Bundle bundle =
                            ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity())
                                    .toBundle();
                    startActivity(intent, bundle);
                } else {
                    Toast.makeText(getActivity(), ((String) item), Toast.LENGTH_SHORT)
                            .show();
                }
            }
        }
    }


    private void loadRows() {
        /* GridItemPresenter */
        IconHeaderItem gridItemPresenterHeader = new IconHeaderItem(0, "More", R.drawable.tv_animation_d);

        GridItemPresenter mGridPresenter = new GridItemPresenter();
        ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter);
        /**
         gridRowAdapter.add(GRID_STRING_EXIT);
         gridRowAdapter.add(GRID_STRING_VIDEOS);

         gridRowAdapter.add(GRID_STRING_VERTICAL_GRID_FRAGMENT);
         gridRowAdapter.add(GRID_STRING_RECOMMENDATION);
         gridRowAdapter.add(GRID_STRING_SPINNER);
         **/
        mGridItemListRow = new CustomListRow(gridItemPresenterHeader, gridRowAdapter);
    }

    private void setRows() {
        mRowsAdapter = new CustumArrayObjectAdapter(new CustomListRowPresenter()); // Initialize

        if(mVideoListRowArray != null) {
            for (CustomListRow videoListRow : mVideoListRowArray) {
                mRowsAdapter.add(videoListRow);
            }
        }
        if(mGridItemListRow != null) {
            mRowsAdapter.add(mGridItemListRow);
        }

        /* Set */
        setAdapter(mRowsAdapter);

    }


    @Override
    public Loader<LinkedHashMap<String, List<Video>>> onCreateLoader(int id, Bundle args) {
        /* Create new Loader */
        Log.d(TAG, "onCreateLoader");
        if(id == VIDEO_ITEM_LOADER_ID) {
            Log.d(TAG, "create VideoItemLoader");
            //return new VideoItemLoader(getActivity());
            return new TvItemLoader(getActivity().getApplicationContext());
        }
        return null;
    }

    @Override
    public void onLoadFinished(Loader<LinkedHashMap<String, List<Video>>> loader, LinkedHashMap<String, List<Video>> data) {
        Log.d(TAG, "onLoadFinished");
        /* Loader data has prepared. Start updating UI here */
        switch (loader.getId()) {
            case VIDEO_ITEM_LOADER_ID:
                Log.d(TAG, "VideoLists UI update");

                /* Hold data reference to use it for recommendation */
                mItems = new ArrayList<Video>();

                /* loadRows: videoListRow - CardPresenter */
                int index = 1;
                mVideoListRowArray = new ArrayList<>();
                TvCardPresenter cardPresenter = new TvCardPresenter();

                if (null != data) {
                    for (Map.Entry<String, List<Video>> entry : data.entrySet()) {
                        ArrayObjectAdapter cardRowAdapter = new ArrayObjectAdapter(cardPresenter);
                        List<Video> list = entry.getValue();

                        for (int j = 0; j < list.size(); j++) {
                            Video movie = list.get(j);
                            cardRowAdapter.add(movie);
                            mItems.add(movie);           // Add movie reference for recommendation purpose.
                        }
                        IconHeaderItem header = new IconHeaderItem(index, entry.getKey(), R.drawable.tv_animation_d);
                        index++;
                        CustomListRow videoListRow = new CustomListRow(header, cardRowAdapter);
                        videoListRow.setNumRows(1);
                        mVideoListRowArray.add(videoListRow);
                    }
                } else {
                    Log.e(TAG, "An error occurred fetching videos");
                }

                /* Set */
                setRows();
        }
    }

    @Override
    public void onLoaderReset(Loader<LinkedHashMap<String, List<Video>>> loader) {
        Log.d(TAG, "onLoadReset");
        /* When it is called, Loader data is now unavailable due to some reason. */

    }



    private class GridItemPresenter extends Presenter {
        @Override
        public ViewHolder onCreateViewHolder(ViewGroup parent) {
            TextView view = new TextView(parent.getContext());
            view.setLayoutParams(new ViewGroup.LayoutParams(GRID_ITEM_WIDTH, GRID_ITEM_HEIGHT));
            view.setFocusable(true);
            view.setFocusableInTouchMode(true);
            view.setBackgroundColor(getResources().getColor(R.color.default_background));
            view.setTextColor(Color.WHITE);
            view.setGravity(Gravity.CENTER);
            return new ViewHolder(view);
        }

        @Override
        public void onBindViewHolder(ViewHolder viewHolder, Object item) {
            ((TextView) viewHolder.view).setText((String) item);
        }

        @Override
        public void onUnbindViewHolder(ViewHolder viewHolder) {

        }
    }

    private final class ItemViewSelectedListener implements OnItemViewSelectedListener {
        @Override
        public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
                                   RowPresenter.ViewHolder rowViewHolder, Row row) {
            // each time the item is selected, code inside here will be executed.
            if (item instanceof String) {                    // GridItemPresenter
                startBackgroundTimer();
            } else if (item instanceof Video) {              // CardPresenter
                startBackgroundTimer();
            }
        }
    }


}


Java:
public class MainActivity extends LeanbackActivity {

    // Init
    private Handler handler = new Handler();
    private Runnable runnable = new Runnable() {
        @Override
        public void run() {
            updateChannels();
            handler.postDelayed(this, 10000);
        }
    };


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        handler.postDelayed(runnable, 10000);

    }

    public void updateChannels(){

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(ApiInterface.JSONURL)
                .addConverterFactory(ScalarsConverterFactory.create())
                .build();

        ApiInterface api = retrofit.create(ApiInterface.class);

        Call<String> call = api.getString();

        call.enqueue(new Callback<String>() {
            @Override
            public void onResponse(Call<String> call, Response<String> response) {
                Log.i("Responsestring", response.body().toString());
                //Toast.makeText()
                if (response.isSuccessful()) {
                    if (response.body() != null) {
                        Log.i("onSuccess", response.body().toString());

                        String jsonresponse = response.body().toString();
                        chkResponse(jsonresponse);

                    } else {
                        Log.i("onEmptyResponse", "Returned empty response");//Toast.makeText(getContext(),"Nothing returned",Toast.LENGTH_LONG).show();
                    }
                }
            }

            @Override
            public void onFailure(Call<String> call, Throwable t) {

            }
        });

    }

    private void chkResponse(String response){

        try {
            //getting the whole json object from the response
            JSONObject obj = new JSONObject(response);
            if(obj.optString("update").equals("true"))
            {

                try {


                    Intent i = new Intent(MainActivity.this, MainFragment.class);
                    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(i);

                } catch (Exception e)
                {
                    Toast.makeText(this, "Error Refreshing Channel Rows.", Toast.LENGTH_SHORT).show();

                }

            }

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

    }
}

Samsung warranty scam

Word of warning: don't ever buy a Samsung phone if you expect to be covered under the one year manufacturer's warranty. They will make up some excuse to not honor your repair!

This is my senario: Model No SM-J810GZKGINS, bearing Serial No- RZ8K70RFANE

I have a brand new Samsung J8 . after couples of months using learning some issues with the battery getting hot and I noticed some other minor issues that seemed to be hardware related. My phone is well within the manufacturer warranty.One day observed while using phone found many limning on phone screen , rush to Croma store. Croma store refer to Samsung service center and finally phone complete down .My phone never been dropped or been exposed to liquid in any way.

I sent it in for service center Feb 2019 , hoping that Samsung would either replace or repair my phone.I followed all the steps to send the phone in for repair, had to get a loaner phone for the time-being, and waited.

Samsung Service center technicians arrived along with Open phone and told that - my phone dipped in water and moniter and Motherboard get damaged and it's not covered under warrenty. They told look phone having water look look this way they are asking me ............... when I try to learn or observed water inside phone . I have not found and I ask where is water .. than service enginner told .. water dry and look this water mark , when i put my fingure on so called water , i observed that stickryness. when i told this is adhesive , they told go way and they wil not entertane this service under warrenty , untill pay Rs. 14800.00 and 4-5 technicians togahter and started fighting with me.
Bottom line is warranty is voided and I have no idea the condition the phone.

I registered complained with Samsung customer care - Firstly they are not ready to understand , somehow able to convince my request , they came back with oprion is , I have to pay Rs.14800.00 for service charges

I asked to customer service - for give prove that my phone dipped in water - they faild to prove at service center and customer service as well or convince , later customer experience manage started Negotiating to me for as a goodwill gesture.

Samsung customer experience team offering me 30% discount , later 40% discount after that 60% discount on repair service.

This process take 90 days and NOT ready to extend the warranty even to pay 40% charges.

After that Samsung customer service NOT replying email and I have no idea the condition the phone will be in when I get it back.

Upon finding this out I called Samsung to hopefully get a solution before they shipped my phone back. Well not surprisingly, I was told nothing could be done because the phone was now marked as having liquid damage. I even spoke with a supervisor and asked for proof of the damage in the form of photos but they refused. Now what do I do?

That's worse case scenario I guess, but still, do yourself a favor and buy an iPhone. At least they honor their warranty and don't make up damage claims they can't prove.
Super disappointed in Samsung india to Indian customers. Share this. Tell everyone you know.

SLAP : AI News APP

So what should you do to read fresh and breaking news at SLAP? There are two simple steps ◀️▶️

Swipe left if world and local news are interesting for you.
Swipe right if the content you see is not interesting for you.

Our artificial intelligence will feel you and learn in real time

And as soon as you like some fresh news from around the whole world, do not be silent!

Share News with your friends

Everything is very simple: you need to click the share button and select the source you want, let it be a social network or a favorite instant messenger. The more you share, the better your environment will be aware of what is interesting for you. Let them share too because you are as curious as they are.

★ Artificial Intelligence works for you

The more friends you invite, the better way artificial intelligence works personally for you. And if your interests coincide, then this can serve as a topic for a great kitchen conversation about hot tech news, or even become the beginning of a new romantic date.

↩️ Swipe, Read News and Share

Modern Internet has a lot of content that is delivered to you through millions of different sources. Every day you look at your feed of breaking news and you drown in the headlines. And you miss most of them because that is not what you really want to read!

⚡️News Application as your Personal Assistant

You go to the smart news app and see only actual and interesting news you like.

✔️ Do you prefer:
– World politics news;
– Hot Tech News;
– Sports news?
Our artificial intelligence will pick you exactly these topics!

But the miracle is that you do not need to subscribe to the loved sources of your preferences. After all, there could be an infinite amount of your interests and the number of categories may be insufficient.


News from Various Countries

You will get local news in the language that is mostly used in your country. But if you suddenly set off on a journey, wish to move abroad, or just want to read breaking news from another country and news in a foreign language, you can always choose what you wish in the settings.

Just News Headlines

Nowadays, people don’t read the full text of the news articles or even a brief description. But the king of the hill is the title at the moment. 5 -10 words are the amount of information that the average user is ready to pick up.

Slap gives an opportunity to the consumers who read the headlines that are interesting to them. You can read all the famous sources that are broadcasting fresh local news within your country in a language that is convenient for you. Get hot headlines about everything you adore, react and share.

★ Artificial Intelligence Shows Best Results

Artificial Intelligence technologies will show you the best personal results. And if you want to get deeply acquainted with this or that information, you can always click Learn more button and go to the original source without leaving Slap, thanks to the in-app browser.

♛ Your News Timeline is Your Choice

One interesting observation: your social circle chooses what you see in the social media timeline. Sometimes it can be frightening, offensive or just uninteresting. Surround yourself only with your own hobbies with Slap news application, and thanks to the self-learning artificial intelligence, that selection of personalized content will amaze you with its accuracy from day to day. In simple words, if you want to create a positive news feed for yourself, do it by yourself.

◀️▶️ Swipe News Left and Right

Swipe simple ways of your finger, look like the movements of a magic wand. Because they are able to set your attitude and brighten up the time you spend on the Internet. And in addition, try to look at your news feed and interests from a different angle. Yes, exactly.

Download SLAP.ai from Play Store

Phone Heating

So one time I left my device (Lenovo A6020a40) on to charge without the screen turning off my internet data was also running next morning the battery was totally drained to 6%. After this the battery drains and heats up when the device is idle I have factory reset it it still persist .Should I change the battery and charger .

Root [ROM][UNOFFICIAL] Lineage 15.1 for J7 Prime SM-G610F

Lineage 15.1 for J7 Prime SM-G610F

This isn't technically my original creation, I just made a newer build of something someone else already started but has since given up on. Either way though I figured I'd mirror it here so it can reach a wider audience. This is Lineage 15.1 for the J7 Prime, SM-G610F variant. If you try to flash this on something else that's not the SM-G610F variant you'll probably have a bad time

As always I am not responsible for what you choose to do to your own phone. Flashing mods like this may void your warranty. Don't come breaking down my door at 2AM if flashing this causes some problem on your device

Please note too that I don't actually own this phone, this was a blind build by me for a friend that has this. I was just going to give him the updated ROM zip but then I figured I'd post it up here for anyone else that wants to use it as well. So be warned that I can't actually test & confirm this works myself (and my friend hasn't flashed it yet either as of me writing this message) so I can't say for certain that it'll work. I'm 99.99% sure it'll work though and I have no reason to BELIEVE it won't, I just can't say for certain yet until him or someone else lets me know

WHAT WORKS:
  • Should be pretty much everything (going off the old ROM build by the original creator)
WHAT DOESN'T WORK:
  • My friend that used the old build told me before that his phone would sometimes best up and apps that shouldn't be slow were really slow (Reddit and Clash Royale namely). But again those were from the old original builds, hopefully this upstreamed one I made is better and fixes some stuff
  • You tell me, since I don't actually have the phone myself
SOURCE CODE:
ROM DOWNLOAD:
SPECIAL THANKS TO:
  • Lineage OS for being there for you, even when the rain starts to pour
  • Everyone in that Exynos7870 github group, because making functioning trees for an exynos chipset is no easy task... yet they actually pulled it off!
  • XDA user DarkLord1731. Again, these builds were originally his, but his last build was from December of last year. By this point I can reasonably assume he has moved onto newer projects (it looks like he's working on Lineage 16 for this phone now, check it out here) and won't be making builds of this anymore--therefore I took the source and made my own version of his original idea, albeit with newer security patches and upstream fixes. Give him the credit for the original idea. He very clearly did this first, he deserves all the real credit!!!!

How to show heads-up notification on Android 7 and older in Kotlin?

I am creating a messaging app and I need to show heads-up notifications on Android 7 and older up to Android 5.

I have created FirebaseMessagingService together with NotificationChannel to show notifications for Android 8 and higher and it works well with heads-up notifications. On Android 7 FirebaseMessagingService onMessageReceived method doesn't work when the app is in the background. So I've decided to use the BroadcastReceiver to show heads-up notifications and now the heads-up notification is shown on Android 7 for several seconds and then it stays in the drawer together with a normal notification. I even commented out FirebaseMessagingService but still get the ordinary notification together with the heads-up notification. I have a feeling that there is another way of implementing this.

3IBc9.png


Here is my code:

MyFirebaseMessagingService file:

Java:
class MyFirebaseMessagingService : FirebaseMessagingService() {

override fun onMessageReceived(remoteMessage: RemoteMessage) {
//      if (remoteMessage.notification !=null) {
//      showNotification(remoteMessage.notification?.title, remoteMessage.notification?.body)
//      }

}
fun showNotification(title: String?, body: String?, context: Context) {

        val intent = Intent(context, SearchActivity::class.java).apply {
            flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
        }
        val pendingIntent = PendingIntent.getActivity(context, 0, intent,
            PendingIntent.FLAG_UPDATE_CURRENT)
        val soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
        val notificationBuilder = NotificationCompat.Builder(context, "my_channel_id_01").apply {
            setSmallIcon(R.drawable.my_friends_room_logo)
            setContentTitle(title)
            setContentText(body)
            setSound(soundUri)
            setDefaults(DEFAULT_ALL)
            setTimeoutAfter(2000)
            setPriority(PRIORITY_HIGH)
            setVibrate(LongArray(0))
        }
        val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
        notificationManager.notify(0, notificationBuilder.build())
    }

Calling the showNotification() from FirebaseBackgroundService file:

Java:
class FirebaseBackgroundService : BroadcastReceiver() {

    var myFirebaseMessagingService = MyFirebaseMessagingService()
    var notificationtitle: Any? = ""
    var notificationbody: Any? = ""

    override fun onReceive(context: Context, intent: Intent) {

       if (intent.extras != null) {
            for (key in intent.extras!!.keySet()) {
                val value = intent.extras!!.get(key)
                Log.e("FirebaseDataReceiver", "Key: $key Value: $value")
                if (key.equals("gcm.notification.title", ignoreCase = true) && value != null) {

                    notificationtitle = value
                }

                if (key.equals("gcm.notification.body", ignoreCase = true) && value != null) {

                    notificationbody = value
                }

            }
            myFirebaseMessagingService.showNotification(notificationtitle as String, notificationbody as String, context)
       }
    }
}

My JSON looks like this:

Code:
{
"to" : "some-id",
  "priority":"high",

"notification" : {
     "body" : "Body of Your Notification",
     "title": "Title of Your Notification",
     "content_available" : true,
     "sound": "sound1.mp3",

     "click_action" : "chat"
},
"data": {
     "uid"  : "yOMX4OagvgXEl4w4l78F7SlqzKr2",
     "method" : "chat",
     "android_channel_id": "1"
   }
}

String definition error

Java:
public String SolicitudServidor(final Activity activity, final String Type, final String Name, final String Surname, final String Username, final String Password){
    String URL, Response;
    if(Type.equals("Register")){
        URL="http://web-androidapp.000webhostapp.com/androidapp/registerUser.php?name="+Name.replaceAll(" ", "%20")+"&surname="+Surname.replaceAll(" ", "%20")+"&username="+Username+"&password="+Password;
    }else if(Type.equals("Check")){
        URL="http://web-androidapp.000webhostapp.com/androidapp/CheckUser.php?username="+Username;
    }
    StringRequest stringRequest=new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            try{
                JSONObject jsonObject=new JSONObject(response);
                Response=jsonObject.getString("Ok");
            }catch (JSONException e){
                e.printStackTrace();
                MostrarPopUp("Error", activity);
            }
        }
    },
            new Response.ErrorListener(){
                @Override
                public void onErrorResponse(VolleyError error){
                    MostrarPopUp("Error", activity);
                }
            });
    RequestQueue requestQueue= Volley.newRequestQueue(activity);
    requestQueue.add(stringRequest);
    return Response;
}

I'm getting an error when using the URL and Response variables. Cannot resolve symbol 'URL' or 'Response'. If I define the variable as final String it appears: Variable 'URL' or 'Response' might not have been initialized.

[ROM]-v9.0 GamerROM Eclipse v1.00 for the Xiaomi Redmi Note 5 (whyred) BETA Released: 05/20/2019!

redmi-note-5-black-2_orig.png

Welcome to

GamerROM ECLIPSE
for the Xiaomi Redmi Note 5 (whyred).


Before we get started i do want to thank MyCats for requesting this port to the Xiaomi Redmi Note 5 and for his source code, without his source code this build would be impossible to make be sure to thank him as well! and all his source code links are at the bottom of this thread!

Let's talk about features most people love having an OS that is fast, lite and makes gaming alot easier without loss of battery life and throttling!

Features:

* Dedicated FM Radio Service (Listen to any radio station world wide on the go).

* Block those pesky ads away with AdAway

* LineageOS 16.0 su binary auto installs when you flash the OS so you can start using your root apps immediately.

* View your PDF files on the go with google's new PDF viewer.

* Get access to instant rewards with Google Rewards Opinions app and earn free play store credit by answering google surveys.

* Built for gaming and daily tasks without slowing down.

* Old Style browser with develop[er settings for devs who want to debug their websites!

and much more.

Known Bugs:

Not sure i personally don't own the device so it's reliant on the community to report them!

Notices:

* Ensure you have an unlocked bootloader

* Ensure your device(s) custom recovery supports flashing ROM(s) LineageOS 16.0+ otherwise you will receive an install error (we recommend using TWRP to flash this OS but is optional).

* If your device supports encryption or is encrypted such as what you see in the nexus 6 where you have to decrypt the nexus 6 in order to boot Android Pie then you should do that 1st before continuing, but if your device isn't encrypted or supports device encryption witch is on by default by the manufacture then you don't have to worry about this part of the notice board this is just to explain if this device has the encryption feature!

* Ensure your system radio, bootloader etc is fully up-to-date before installing to get the best connectivity with ctOS(R)Network Severs and cellular connectivity!

DAMAGES NOTICE: as a developer sometimes in development things go not as planned so ensure you backup your data, as "Cyberdev" is not responsible of any kind of damages occur during the installation or use of this OS, DO NOT REPORT BUGS if you altered the OS in a way where we haven't implemented ourselves. We will ignore and not fix your problem.

GAPPS Notice: Gapps do not affect the the system applications built in GamerROM Eclipse, however we HIGHLY RECOMMEND you not to install gapps beyond the "Full" packages as it will either create duplicate apps or remove important apps this also counts as modifying the OS beyond what we implemented and the full package will not remove any current apps built-in!

OS Released on date: 05/20/2019

Version: v1.00

Download: https://play.google.com/store/apps/details?id=com.gamerrom.downloader

Thanks to MyCats for the source code view below his source code below:

MyCats Device Tree: https://github.com/MyCats/android_device_xiaomi_whyred

MyCats Kernel SRC: https://github.com/GuaiYiHu/android_kernel_xiaomi_whyred

MyCats Vendor SRC: https://github.com/GuaiYiHu/android_vendor_xiaomi_whyred

My Mediacom PhonePad Duo can't factory reset

So I was given this tablet by my parents and I can't seem to access it, someone wiped the eMMC before and now it requires a google account that was previously used. How do I factory reset it? I tried holding down the power volume down button and power button but it only gave me the options listed below:
Auto Test
Manual Test
Item Test
Test Report
Debug test
Clear eMMC
Version
Reboot

No factory reset/wipe option.

Move to sd

The playstore is full of apps that move things to sd card. How many of them actually work (without root)? I would love to root this S5 but for now it's unlikely. I just want to move everything I possibly can from phone storage to sd. After all, the S5's got only 16 gb, but it's still better than 8.

Action Launcher change color notification bar

1.
The top row (aka "Notification Bar") background is much too dark to see the icons. I new to Android and Action Launcher, and I can't figure out how to resolve this by:

A. Making the icons white instead of black, or
B. Lightening the background (I think I figured out that the Action Launcher setting for "Status Bar" controls the "Notification Bar" shading, but the only options it offers me are black and a dark gray that doesn't contrast enough with black icons.)

I'm also confused by that while the "Notification Bar" background is too dark with nothing open, if I open, say, Settings for Action Launcher or Android then the "Notification Bar" background lightens up significantly and acceptably.

2.
Oh, and speaking of the Settings screen backgrounds for Action Launcher and Android, is there some way to make them darker (or am I stuck with white)?

I've got Android 9 on Moto G7 with Action Launcher 40.1

Huawei and Honor phones. Buy? / Don't buy!?

Is this a bad time to buy (or own or just have purchased) a Huawei or Honor phone.

Will prices drop dramatically?

Is Google getting ready to completely say bye bye to Huawei, or stopping updates is the most they can do?

Should someone be warning people about investing in a Huawei phone?

Is it just the same here in the UK now as in the States?

Is it not so bad at all?

If you fail to answer every question my butt might hurt :p

I need a phone as the one I have is heading for life support.

I like their phones, their low mid range phones are where I would head.

I also like Motorola and Nokia, but the G7 Plus I'm getting meh about, the Nokia 7 Plus would have been for me, but they sold out at a great £200, and I'm looking at the Nokia 8.1 down to 269 ish.

Lots of Huawei and Honor to chose from, but this Google news is bad, huh?

Power on when charging but only when battery level is greater than 20%

I have recently tried to fit a tablet into my car and I came across a problem with waking up the device without using the power button.
My solution is to boot the device whenever it is charging, but I have noticed that when the battery level is at 0%, the device boots and then immediately shuts down.
I have used this adb option to trigger this behavior:

fastboot oem off-mode-charge 0

However this boots the phone without checking the battery level and as I said -
if the battery is dead, the phone (or rather a tablet- Nexus 7 2012) turns off immediately -
it drains the battery faster that I'm able to charge it. Is there any way to make the tablet boot only if the battery level is greater than, say, 20%?

App for automatically switching on/off a SIM card

Hi there,

I am new to the forum and wanted some advice on Android apps. I hope someone will respond.

Is there any Android 8.0 application to automatically switch off the SIM at night and switch it on in the morning. I will be delighted to use such an app (I keep receiving phone calls in the night and at times forget to switch of the SIM). If not, is there any way to do so otherwise?

Looking forward to your response.

Thanks and Regards,
Arvind Gupta

Filter

Back
Top Bottom