I want to distinguish between valid and invalid URL (which makes no sense). So that I could write my logic code accordingly.

protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        final IntentResult result=IntentIntegrator.parseActivityResult(requestCode,resultCode,data);

//As a parameter we are receiving URL similar to https://myapp-17a2f.firebaseio.com/55dd5vf78rv12vrw6w59w1aa0dhjm
public void convertToAddress(String scannedID){

        DatabaseReference databaseReference=firebaseDatabase.getReference(scannedID);
//Here I need the logic to check whether databaseReference variable got valid URL or invalid URL
        Log.e(TAG,"ConvertToAddress: Address is "+ databaseReference.toString());
        databaseReference.addListenerForSingleValueEvent(new ValueEventListener() {
          public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
             //Code Goes here

          public void onCancelled(@NonNull DatabaseError databaseError) {


The output it should produce is

if(logic to check valid URL) {
     Toast("This URL is valid");
} else{
     Toast("This URL is invalid");

0 Answers