小编Twi*_*led的帖子

检测Android应用程序是否在"BlueStacks"中运行的可靠方法

我想在Android应用程序内的运行时确定它是否在BlueStacks Android模拟器中运行.这样我就可以在BlueStacks中运行时修改应用程序的运行方式.

BlueStacks不支持多点触控,因此我想实现当前应用程序具有的标准双指缩放功能的替代方案.

例如

If (appIsRunningInBlueStacks){
    mySurfaceView.enableMultiTouchAlternatives();
} else{
    mySurfaceView.enableMultiTouchFeatures();
}
Run Code Online (Sandbox Code Playgroud)

确定appIsRunningInBlueStacks值的可靠方法是什么?

编辑有关问题的评论答案摘要:

Ben,Taras,感谢您的建议.BlueStacks的Build.MODEL等值是:

  • 型号:"GT-I9100"

  • 制造商:"samsung"

  • 装置:"GT-I9100"

  • 产品:"GT-I9100"

这是与三星Galaxy SII相同的型号,所以使用它不是理想的,因为担心使用与BlueStacks相同的SII处理所有用户.

CommonsWare,该应用程序继续在BlueStacks中运行,即使清单中的<uses-feature>用于多点触控.事实上(也回答了iagreen的问题)......

packageManager.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT);
Run Code Online (Sandbox Code Playgroud)

......回归真实!我想这是可以预料的,因为模拟器确信它是三星Galaxy SII!

因此,我们仍然没有办法可靠地检测应用程序是否在BlueStacks上运行而不会将所有三星Galaxy SII用户放在同一个存储桶中.还有其他想法吗?

java android emulation android-emulator bluestacks

15
推荐指数
2
解决办法
5172
查看次数

Java为两个可互换的整数重写equals()和hashcode()

我重写了两个int的简单容器对象的equals和hashcode方法.每个int都反映了另一个对象的索引(该对象是什么并不重要).该类的要点是表示两个对象之间的连接.

连接的方向无关紧要,因此无论两个整数在对象中的哪个方向,equals方法都应该返回true.

connectionA = new Connection(1,2);
connectionB = new Connection(1,3);
connectionC = new Connection(2,1);

connectionA.equals(connectionB); // returns false
connectionA.equals(connectionC); // returns true
Run Code Online (Sandbox Code Playgroud)

这是我所拥有的(从Integer的源代码修改):

public class Connection {
    // Simple container for two numbers which are connected.
    // Two Connection objects are equal regardless of the order of from and to.

    int from;
    int to;

    public Connection(int from, int to) {
        this.from = from;
        this.to = to;
    }

    // Modifed from Integer source code
    @Override
    public boolean equals(Object obj) {
        if …
Run Code Online (Sandbox Code Playgroud)

java hash-code-uniqueness equals hashcode

9
推荐指数
2
解决办法
2819
查看次数

Force Proguard给一个类中的每个方法一个唯一的名字?

我正在使用Proguard来混淆Android应用程序.一切正常,但我正在努力从错误报告中回溯堆栈跟踪.

这是我混淆代码的摘录:

    private ez a(x paramx)
  {
    return (ez)this.J.get(paramx);
  }

  private void a(com.b.a.f paramf)
  {
    Iterator localIterator = this.K.iterator();
    while (true)
    {
      if (!localIterator.hasNext())
        return;
      em localem = (em)localIterator.next();
      if (localem.a((int)(this.i / this.m - 202.0F), (int)(202.0F + (this.i + this.n) / this.m), (int)(this.j / this.m - 202.0F), (int)(202.0F + (this.j + this.o) / this.m)))
        localem.a(paramf, this.m, this.i, this.j);
    }
  }

  private void a(com.b.a.f paramf, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    Iterator localIterator = this.J.entrySet().iterator();
    while (true)
    { …
Run Code Online (Sandbox Code Playgroud)

obfuscation android proguard

6
推荐指数
1
解决办法
2122
查看次数