Issue with FCM in Android Studio

Hi DW, I've faced an issue with my project, it has been working these years till I think last year or the other year. When I sync it fails saying unable to resolve dependency no matter which version I try I get similar error differs with version number.

Unable to resolve dependency

Hi DW, I'm having an issue on my Android studio I'm getting this error Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.gms:play-services-measurement-api:[16.0.3].
Does anyone know how to solve this error?

Create a dynamic list name

Hi DW. Anyone who knows how can I achieve this? List<String> dynamic[i];
The reason why I need this is that I'm creating a dynamic list with nested lists so there's no fixed number of data the list can be, this is inside the for statement which receive the json data which is multidimention array so I want for each item in the json data create 1st the parent list then create nested list for it.

Currently it mixes data and I see that it because of this.

How to virtualise my android to web

Hi DW. Is there anyone who know how I can I develop an App that's like TeamView for Android so that I will be able to remotely access the phone via browser on my website?
What I want to do is that instead of directly accessing the phone I want to virtualise it so that I can have duplicates of it when required so that let say 2 people are accessing or using it, they won't be interference from the two but each will have his own clone (virtual) device. I want then to share the virtual device screen on my website.

The use case of this is very simple it's just for viewing while, going to settings, dial a USSD code and see a response.

The catch here is that we all know that the actual devices are not the same interms of operation so it must clone that device behaviour so that the user will be like using the very same device.

How can I achieve this? I think the steps is to first clone the entire device, I don't know how, then create a virtual device of it which the user will be interacting with rather than interacting with the actual device because that will mean I will have to have many device if th number grows so I think best way is to virtualise it so that I can have duplicates of it unless if there's another way of threading the remote access which might be best if possible.

1)Android App to allow the remote access
2) server that will receive the access and broadcast it to website so that a user can select. NB there will be many different devices which a user will be able to choose from say if the user want to use a P40 Lite, or want to use A7, or want to use Y6, etc the virtualisation should give the user exactly the device feel for that selected device so I think buying one of each then virtualising it would be best.
3) user on the website select a device to use, the the session or remote access begins.

How can I achieve that?
Thank you

Get a child class name value of the clicked element

Hi DW. I have code:

<div class="lv-item media">
<div class="lv-avatar bgm-purple pull-left">u</div>
<div class="media-body">
<div class="lv-title">dynamically_generated_value</div><!-- I want to get this value -->
<div class="lv-small">Sample text</div>
</div>
</div>

I use the following code to activate the selected list. NB the above is also dynamically generated for simplicity let say we have the above code with a unique lv-title value as it's the user chat id so it unique. And I want when I click this element I want to get that child class by name of the selected item. Here's the code I use to set the active when the user click the element.

var chatheader = document.getElementById("uchatlist");
var lvitem = chatheader.getElementByClassName("lv-item media");
for(var i = 0; i < lvitem.length; i++){
lvitem[i].addEventListener("click", function (){
var lvitemcurrent = document.getElementByClassName("lv-item media active");
lvitemcurrent[0].className = lvitemcurrent[0].className.replace(" active","");
this.className += " active";
// Here is where I want to get the title value of the clicked element. 
});
}

NB the fist code is inside a div with a class uchatlist

What I'm doing is a chat system on the left it has a list of users which is what when you click I want to get its title value so that I will be able to show and hide the messages or chats on the right hand side for the selected user. On the right it's where the end user and chat and see the response messages as well. So I want to show this for each user when the user is being clicked from the left and show its chats on the right.

Get one item of duplicate if found

Hi DW. I'm creating a chat system which will alow guests to send DMs to the operator and the operator can reply to it. I'm using MYSQL as my database, fingerprint2js for identifying the user since user has not yet logged in or registered but want to first communicate with the admin.

Scenario here is that the user has sent 2 messages which are bot recorded separately on the database but have the same uid which is the id used to identify the user. My problem is that even the admin when replay he will also use this same uid so the uid is having many duplication as they communicate, issue is that it's not only the two people communicating but others as well which makes it have many duplicates of each uid.
What want to achieve withe the select is to get only a single uid of each even if its its duplicate or not but get one of each so that will be able to iterate through each user and be able to sort their messages for displaying purpose. At the moment I have 2 rows with the same uid but when I use select and while since the number of rows are two it runs twice which end up producing same result twice. On the display side get 4 messages because for each iteration it return both rows when on my select statement I select where uid equal id which is returned by a select all from xchat table where msgfrom equal user. This returned all the uids of the messages since it's only the user that starts a chat now the issue is that a user or admin can send more than one message, how can I get all uids but for duplicates only get 1 id of each so that when I work with it only work once even if there are more than one same uid on the database and also get those that are not duplicates as well.

Thanks.

Unable to resolve firebase 17.0.4

Hi DW, I'm experiencing an issue I've tried invalidating, fixed the offline sync but still I'm getting this error. My App uses Firebase FCM.

On the dependencies I have com.google.firebase:firebase-core:16.0.5 com.google.firebase:firebase-messaging:17.3.4

My implementation com.android.support:appcompact-v7:28.0.0-alpha1

This implementation is underlined with a red line and I think it is what having the issue, i remember now when I had this kind of error before I saw a post that said I must change the version here but don't know to which version to change to. If anyone know how can I fix this error please help me out. Thanks

Send message to a specific context script tab

Hi DW.

I want to get a message only on that specific targeted tab id. If the messege is sent to tab id 2, it should run a script under tab id 2 to update that page displayed or for simplicity log on tab id 2 console the message.

The tab id is from background script so it then sends a message to that tab id, here is an example:

chrome.webNavigation.onCompleted.addListener(function(details){
    doThis("my_Message", details);
    }

    function doThis(msg, to){
    chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
        //console.log("vvv: " + tabs[0].id);
        chrome.tabs.sendMessage(to.tabId, {action: msg, data: "test"}, function(response){
            if(chrome.runtime.lastError) {
      const rw = setTimeout(() => {doThis(msg);}, 1000);
     clearTimeout(rw);
    } else {
            console.log("Message sent from background");
    }
        });
    });
}

Now my receiving part:

chrome.runtime.onMessage.addListener(function(msg, sender, response){

console.log(sender.id);
console.log(msg);
return true;
}

How to dynamically display a popup

Hi DW.

I'm trying to display a popup over an input box, but the issue is that some websites that I want to also display on have div class name that contains many classes in it which result it a div class name to have spaces in it which is not a problem.

I would have used id for this but the issue is that some site doesn't have the ids. if you would take the facebook sample code:

<div class="_6lux">
<div class="_6luy _55r1 _1kbt" id="passContainer">
<input type="password" class="inputtext _55r1 _6luy _9npi" name="pass" id="pass" data-testid="royal_pass" placeholder="Password" aria-label="Password" />
<div class="_9ls7" id="u_0_b_sX">
<a href="#" role="button">
<div class="_9lsa">
<div class="_9lsb" id="u_0_c_3V">
</div>
</div>
</a>
</div>
</div>
</div>

So with the above what I want is to get the div with class _6lux because this work if I use that div but if I use any element inside that div it doesn't work correctly. The popup I want to show on a password field of that particular open website is Popup source link

Now if you also take Daniweb as another example code is

<div class="form-group">

<label for="password901886946" class="control-label d-none">Password</label>

<input type="password" class="form-control" id="password901886946" name="password" placeholder="Password">

</div>

And for Daniweb it work correctly with this div with class form-group. What I'm trying to do is to be able to dynamically locate the correct div that will correctly display this popup over the password field. I inject the same css code from the above link to the open website then also inject

var popup = document.getElementById("mypopup");
  popup.classList.toggle("show");

which triggers to display or hide the popup. My full css and dynamic selecting of the div code is

var inputs = document.getElementsByTagName('input');
    var dynamicclass;

for(var i = 0; i < inputs.length; i++) {
    if(inputs[i].type.toLowerCase() == 'password') {
        // Trying to get the id of this element
         var eid = inputs[i].id
         parentDiv = inputs[i].parentNode;//.className;

        if(parentDiv.className.includes(" ")){
        // Here was trying to switch from class to ID of the actual field but it doesn't work
        dynamicclass = "#"+inputs[i].id;
        }else{
            dynamicclass = "."+parentDiv.className;
        }
    }
}


    document.getElementsByTagName('head')[0].insertAdjacentHTML("beforeend","<style>"+dynamicclass+" {position: relative;display: inline-block;cursor: pointer;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;}"+dynamicclass+" .popuptext {visibility: hidden;width: 160px;background-color: #555;color: red;text-align: center;border-radius: 6px;padding: 8px 0;position: absolute;z-index: 1;bottom: 125%;left: 50%;margin-left: -80px; backgroundColor: red;}"+dynamicclass+" .popuptext::after {content: '';position: absolute;top: 100%; left: 50%;margin-left: -5px;border-width: 5px;border-style: solid;border-color: #555 transparent transparent transparent;}"+dynamicclass+" .show {visibility: visible;-webkit-animation: fadeIn 1s;animation: fadeIn 1s;}@-webkit-keyframes fadeIn {from {opacity: 0;} to {opacity: 1;}}@keyframes fadeIn {from {opacity: 0;}to {opacity:1 ;}}</style>");

document.getElementById(eid).insertAdjacentHTML("beforebegin","<span class='popuptext' id='mypopup'>A Simple Popup!</span>");

The above work well with Daniweb. So my question is how can I make this work for all websites which I also don't know but it would be best if this can work on the majority of the websites.

Theory on the VPN

Hi DW.

I'm a bit confused and lost on how this App is working called Ha Tunnel Plus (You can check it on Playstore, and have a look on YouTube for the configuration file). Basically it somehow uses the internet connection of the server, it tunnels it to your Android device and you can be connected to the internet without having data on your mobile network sim card, but you can use internet just like you would normally do except that this is not limited on how much data you as a user is using.

I tried playing around with the bunch of source codes I found on github but they don't connect, so since I was trying to connect using on of the IP address that worked on Ha Tunnel Plus, I thought it would also work in my App but it didin't, and I thing that .hat configuration file is the certificate because I found some encrypted data but it just text.

In my case I want to be able to limit this internet access only to my App, also be able to dynamically change this so the entire phone can use it. I don't want a user to select the countries nor see it rather randomly do that at the background, but first thing first. for this kind is it reversing internet connetion or what? How does this work exactly because others I saw they work only if you have data otherwise it doesn't connect. Another that I saw from YouTube to be working is NPK Tunnel, TLS Injector. Anyone know how these Apps work?

Thank you.

Get the device name

Hi DW.

Anyone knows how I can get the device name the browser is running on? I mean something like on the attached image with Javascript?

FireFox_SendTo.PNG

Java heap size issue

Hi Dw.

I had java 8 installed I'm, the problem is that when I run a bat file that uses the java it says Invalid maximum heap size -Xmx4g. I've even tried to uninstall and reinstall java but the same problem persists.

I've added the Xms as well as Xmx in the environment property window but still the same issue, I've restarted the laptop after every attempt but still.

I've even set it on Java Control Panel as well but still the same issue is raised. Anyone who might know another location as to where is this 4g coming from because I don't recall setting that.

How can I create a game like 8ball

Hi, I'm curious on how and which tools are used to develop an 8 ball pool game. The one I'm referring to is that you play online with strangers, and friends for coins and tournaments.

Can anyone point me to the right direction. This will be my first attempt in game development, but I'm a full stack developer and a software developer with Java, VB.NET, C++ ( very new)

4IR Data privacy

Hi DW.

Well I'm very much interested in the data protection and also giving the best privacy to the public where we protect your passwords. I've seen something that Firefox had introduced to their browsers with also their Apps. This is called LockWise which is a tool to sync your passwords with your other devices.

Now as we are in the 4IR I personally think that such information shouldn't be shared purely with other devices because what will happen when you are not in front of those devices?

Worst of them all we all know that browsers don't encrypts the passwords so this to me opens a very huge security loophole because a person with access to let say your computer can see and copy your passwords as the browsers saves the actual passwords.

With that in mind check BRIWPED on YouTube see the demonstration on this live. I think as we are in the 4IR the only person should know the actual password is the owner only. I don't see a reason why would we still submit the actual password over the internet whereas we can only use the encryption systems like BRIWPED to ensure that only the salts is sent and on the server the encryption MD5 or encrypted RSA1 or any encryption is used so that even on the server there will be no actual user password is received but rather the MD5, RSA1 or any other.

This will make it more harder to hack provided that the user also have AV installed to his computer.

Tools like BRIWPED makes it easy to share like LockWise but not the actual password is shared but the salts which there can be verification to ensure that if the login is to be granted to a site or App but it from the actual user.

What also nice with BRIWPED is that they also have an App that gives you instant notification when there is a login activity and with the App you can instant stop that login.

It can also be used on any website. As we are in the 4IR sensitive information like your passwords should be kept secure and private at all times so only you yourself knows it and not even your browsers or server because what if your browsers or your server gets hacked?

What do you think of this, do you agree that such services and tools like LockWise and I also saw a video on YouTube with the smart key which also carries your passwords and you don't have to type the passwords on the browsers because these keys automatically submit or type it to the browser for you.

We've also seen what had happened to the contactless on the smart cards where hackers now target it and hack it without even touching you. So such things with also happen with the passwords if they are not encrypted at all times.

What is your view on these security issues that are within the 4IR?

Null FCM message

Hi DW.

I'm developing an App that uses the FCM notification, but the problem is that my code doesn't seem to get the actual data like when I extract the message or body it shows just the icon only if the notification was received when the App is open, and it shows the title and body if the notification is received when the App is not running.

Basically what I'm trying is to get the message and put that on a textView so that it is seen on the actual App when you click the notification.

Here is my FirebaseMessagingService code:

public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService {

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
      showNotification(remoteMessage.getData().get("body"));
    }

    private void showNotification(String message) {
        Intent i = new Intent(this,MainActivity.class);
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        //if(message != "") {
            //i.putExtra("message",message);
        //}
        PendingIntent pendingIntent = PendingIntent.getActivity(this,0,i,PendingIntent.FLAG_UPDATE_CURRENT);
        NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                .setAutoCancel(true)
                .setContentTitle(message)
                .setContentText(message)
                .setDefaults(Notification.DEFAULT_SOUND)
                .setStyle(new NotificationCompat.BigTextStyle().bigText(message))
                .setContentText(message).setLights(Color.GREEN, 300, 300)
                .setVibrate(new long[] { 100, 250 })
                // .setSmallIcon(R.drawable.common_google_signin_btn_icon_dark)
                .setSmallIcon(R.drawable.blogo)
                .setContentIntent(pendingIntent);

        NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

        manager.notify(0,builder.build());

        //startActivity(i);
    }
}

My MainActivity code:

protected void onCreate(Bundle savedInstanceState)  {
        super.onCreate(savedInstanceState);
        // remove title
       this.requestWindowFeature(Window.FEATURE_NO_TITLE);
       /* getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);*/

        setContentView(R.layout.activity_main);
        txtStatus = (TextView) findViewById(R.id.txtStatus);
//if(getIntent().hasExtra("message")){
if (getIntent().getExtras() != null && getIntent().getExtras().containsKey("message")) {

    Intent intent = new Intent(MainActivity.this,Main3Activity.class);
    //extras.getString("body")
    Intent i = getIntent();
    Bundle extras = i.getExtras();
    String mmsg = "9";
    if (extras != null) {
        for (String key : extras.keySet()) {
            Object value = extras.get(key);
            //Log.d(Application.APPTAG, "Extras received at onCreate:  Key: " + key + " Value: " + value);
            mmsg = extras.getString("message");
        }
        //String title = extras.getString("title");

        if (mmsg != null && mmsg.length() > 0) {
            //getIntent().removeExtra("message");

//
        }
    }
    txtStatus.setText(mmsg);
    intent.putExtra("nmsg", mmsg);
    startActivity(intent);
}else{
txtStatus.setText("Not set");

    ctoken = FirebaseInstanceId.getInstance().getToken();

    String data = "action=check&token=" + ctoken;
    goData = data;
    new MainActivity.MakeNetworkCall().execute("http://my_server_url" + data, "Post");
//    txtStatus.setText("Please wait...");

}

    }

my server script that sends notifications to FCM and down to the App code:

<?php

    $payload = array(
    'to'=>'this_is_the_App_token',     
    'priority'=>'high',
          "mutable_content"=>true,
          "notification"=>array(
                      "title"=> 'Alert title',
                      "body"=> 'This is a body message.',
                      "sound"=> "default",
                      "message"=> "This is the main message"
          ),
          'data'=>array(
                'action'=>'models',
                'model_id'=>'2701',
              )
        );
    $headers = array(
      'Authorization:key=my_auth_key_here',
      'Content-Type: application/json'
    );
    $ch = curl_init();
    curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
    curl_setopt( $ch,CURLOPT_POST, true );
    curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
    curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
    curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $payload ) );
    $result = curl_exec($ch );
    curl_close( $ch );
    var_dump($result);exit;
?>