我的Andr​​oid应用被报有病毒 [英] My Android app is reported to have a virus

查看:132
本文介绍了我的Andr​​oid应用被报有病毒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经上传在Play商店的应用程序,我已经收到了若干意见,它中有一个病毒,它有时会强制移动到重启。在我的应用程序的code是如此简单:只有一个有几个斑点,要么你可以听到他们或将它们设置为铃声的活动。你可以建议我什么?

code我的应用程序:

  b1_2.setOnClickListener(新View.OnClickListener(){
  公共无效的onClick(视图v){
    如果(另存为(soundid,save_name)){
      Toast.makeText(Main.this,声音设置为铃声!
        Toast.LENGTH_LONG).show();
    };
  }
});
公共布尔另存为(INT ressound,字符串文件名){
  字节[]缓冲= NULL;
  InputStream的FIN = getBaseContext()getResources()openRawResource(ressound)。
  INT大小= 0;
  尝试{
    大小= fIn.available();
    缓冲区=新的字节[大小]
    fIn.read(缓冲液);
    fIn.close();
  }赶上(IOException异常五){
    // TODO自动生成catch块
    返回false;
  }
  字符串路径=/ SD卡/媒体/铃声/;
  布尔存在=(新文件(路径))存在();
  如果(存在!){新的文件(路径).mkdirs();}
  FileOutputStream中保存;
  尝试{
    保存=新的FileOutputStream(路径+文件名);
    save.write(缓冲液);
    save.flush();
    save.close();
  }赶上(FileNotFoundException异常五){
    // TODO自动生成catch块
    返回false;
    }赶上(IOException异常五){
      // TODO自动生成catch块
      返回false;
    }
    sendBroadcast(新意图(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
      Uri.parse(文件://+路径+文件名)));
    文件k =新的文件(路径,文件名);
    ContentValues​​值=新ContentValues​​();
    values​​.put(MediaStore.MediaColumns.DATA,k.getAbsolutePath());
    values​​.put(MediaStore.MediaColumns.TITLE,夹_+ save_name);
    values​​.put(MediaStore.MediaColumns.MIME_TYPE,音频/ MP3);
    values​​.put(MediaStore.Audio.Media.ARTIST,夹);
    values​​.put(MediaStore.Audio.Media.IS_RINGTONE,真);
    values​​.put(MediaStore.Audio.Media.IS_NOTIFICATION,真);
    values​​.put(MediaStore.Audio.Media.IS_ALARM,真);
    values​​.put(MediaStore.Audio.Media.IS_MUSIC,真);
    //把它插入到数据库
    URI的uri = MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath());
    getContentResolver()。删除(URI,MediaStore.MediaColumns.DATA += \\+
      k.getAbsolutePath()+\\,NULL);
    乌里newUri = this.getContentResolver()插入(URI,价值观)。
    RingtoneManager.setActualDefaultRingtoneUri(
      对此,RingtoneManager.TYPE_RINGTONE,newUri);
    返回true;
  }

所需的权限:

 <使用许可权的android:NAME =android.permission.WRITE_EXTERNAL_STORAG​​E/>
    <使用许可权的android:NAME =android.permission.WRITE_SETTINGS>< /使用许可权>
     <使用许可权的android:NAME =android.permission.INTERNET对/>
    <使用许可权的android:NAME =android.permission.ACCESS_NETWORK_STATE/>

它的工作原理没有互联网,但我只是在谷歌Play商店的直接链接到我的网页开发人员,为了避免崩溃我已经使用这个功能:

 (如果链接pressed)
  如果(isOnline()){
    打开页面
}其他{
  没做什么
}
公共布尔isOnline(){
        布尔connectedWifi = FALSE;
        布尔connectedMobile = FALSE;        ConnectivityManager厘米=(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
        的NetworkInfo [] =网络cm.getAllNetworkInfo();
        对于(NI的NetworkInfo:网络){
            如果(WIFI.equalsIgnoreCase(ni.getTypeName()))
                如果(ni.isConnected())
                    connectedWifi =真;
            如果(移动.equalsIgnoreCase(ni.getTypeName()))
                如果(ni.isConnected())
                    connectedMobile =真;
        }
        返回connectedWifi || connectedMobile;
    }


解决方案

首先,你的Andr​​oid应用有病毒这一概念是愚蠢的。如果没有的<​​em>恶意code 的在你的应用,那么它是因为你开发了恶意code你的应用在里面。

什么是更可能发生在这里的是,你的应用程序中有一个BUG。更糟的是,你的用户(S)使用还了Android SDK中有一个错误(因为操作系统崩溃而绝不应该发生)。如果没有经历和分析所有code,那将是pretty任何人都很难在这里给你一个直接的答案,在这里你的code中的错误和/或Android的SDK

我建议搞清楚什么设备和SDK版本这个bug已经经历了,然后我就开始对这些设备/软件开发工具包测试应用。既然你认为错误可能与互联网连接,测试与互联网连接的应用程序启用,禁用和弱连接。请记住,它可能是你正在运行到了previous Android SDK中一个已知的bug。

您也可以与您的推出下一个版本的 Crittercism (或其他类似的库)安装到帮助您跟踪崩溃。

I have uploaded an app in the Play store and I have received several comments that it has a virus in it and it sometimes forces the mobile to reboot itself. The code in my app is so simple: only one activity that has several spots and either you can hear them or set them as a ringtone. Can you suggest me anything?

Code of my app:

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;
  }

Permissions required are:

  <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 internet but I just have a direct link to my developers page in google play store and in order to avoid crashes I have used this function:

(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;
    }

解决方案

First of all, the concept that your Android app "has a virus" is silly. If there is malicious code in your app, then it is because you developed your app with malicious code in it.

What is more than likely happening here is that your app has a BUG in it. Even worse, the Android SDK that your user(s) are using also has a bug in it (because the OS is crashing and that should never happen). Without going through and analyzing all of your code, it's going to be pretty hard for anyone on here to give you a direct answer as to where the bug in your code and/or the Android SDK is.

I would suggest figuring out what devices and SDK versions this bug has been experienced with, and then I would start testing the app on those devices/SDKs. Since you think the bug may be related to internet connection, test the app with internet connection enabled, disabled, and with a weak connection. Keep in mind that it is possible that you are running into a known bug in a previous Android SDK.

You could also launch your next version with Crittercism (or another similar library) installed to help you track down the crash.

这篇关于我的Andr​​oid应用被报有病毒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆