It is reported that my Android application has a virus

I uploaded the application to the Play Store, and I received a few comments that it has a virus, and sometimes it causes the mobile station to reboot. The code in my application is so simple: only one action has several points, and you can hear them or set them as a ringtone. Can you offer me something?

My application code:

b1_2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if(saveas(soundid,save_name)){ Toast.makeText(Main.this, "The sound was set as ringtone!", Toast.LENGTH_LONG).show(); }; } }); public boolean saveas(int ressound,String filename){ byte[] buffer=null; InputStream fIn = getBaseContext().getResources().openRawResource(ressound); int size=0; try { size = fIn.available(); buffer = new byte[size]; fIn.read(buffer); fIn.close(); } catch (IOException e) { // TODO Auto-generated catch block return false; } String path="/sdcard/media/ringtones/"; boolean exists = (new File(path)).exists(); if (!exists){new File(path).mkdirs();} FileOutputStream save; try { save = new FileOutputStream(path+filename); save.write(buffer); save.flush(); save.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block return false; } catch (IOException e) { // TODO Auto-generated catch block return false; } sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://"+path+filename))); File k = new File(path, filename); ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath()); values.put(MediaStore.MediaColumns.TITLE, "clip_"+save_name); values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3"); values.put(MediaStore.Audio.Media.ARTIST, "clip"); values.put(MediaStore.Audio.Media.IS_RINGTONE, true); values.put(MediaStore.Audio.Media.IS_NOTIFICATION, true); values.put(MediaStore.Audio.Media.IS_ALARM, true); values.put(MediaStore.Audio.Media.IS_MUSIC, true); //Insert it into the database Uri uri = MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath()); getContentResolver().delete(uri, MediaStore.MediaColumns.DATA + "=\"" + k.getAbsolutePath() + "\"", null); Uri newUri= this.getContentResolver().insert(uri, values); RingtoneManager.setActualDefaultRingtoneUri( this, RingtoneManager.TYPE_RINGTONE, newUri); return true; } 

Required Permissions:

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

It works without the Internet, but I have a direct link to my developers page on the Google Play Store and I used this function to avoid crashes:

 (if link is pressed) if (isOnline()){ open page } else { do nothing } public boolean isOnline() { boolean connectedWifi = false; boolean connectedMobile = false; ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo[] networks = cm.getAllNetworkInfo(); for (NetworkInfo ni : networks) { if ("WIFI".equalsIgnoreCase(ni.getTypeName())) if (ni.isConnected()) connectedWifi = true; if ("MOBILE".equalsIgnoreCase(ni.getTypeName())) if (ni.isConnected()) connectedMobile = true; } return connectedWifi || connectedMobile; } 
+4
source share
1 answer

First of all, the idea that your Android application has a virus is stupid. If your application has malicious code, it is because you have developed your application with malicious code.

What is more than likely happening here is that your application has a BUG. Worse, the Android SDK that your user (s) uses also has an error in it (since the OS is crashing and this should never happen). Without missing or analyzing all your code, it will be very difficult for anyone here to give you a direct answer about where the error is in your code and / or Android SDK.

I would advise finding out which devices and SDK versions occurred with this error, and then I will start testing the application on these devices / SDKs. Since you think the error may be related to your Internet connection, check out the application with the Internet connection turned on, disconnected and a weak connection. Keep in mind that it’s possible that you are using a known bug in the previous Android SDK.

You can also run the next version with Crittercism (or another similar library) to help you track crashes.

+2
source

All Articles