GVKun编程网logo

android – 什么时候使用了cell tower triangulation?(android什么时候出来的)

17

如果您对android–什么时候使用了celltowertriangulation?感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于android–什么时候使用了cellto

如果您对android – 什么时候使用了cell tower triangulation?感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于android – 什么时候使用了cell tower triangulation?的详细内容,我们还将为您解答android什么时候出来的的相关问题,并且为您提供关于Android Animation Interpolator - Android 动画插值器分析、android emulator setting & configuation、Android java.lang.ClassCastException:无法将android.widget.RelativeLayout强制转换为android.widget.EditText、android MediaPlayer NullPointerException的有价值信息。

本文目录一览:

android – 什么时候使用了cell tower triangulation?(android什么时候出来的)

android – 什么时候使用了cell tower triangulation?(android什么时候出来的)

当网络用于定位时,这些无线网络是广播其ID,还是网络实际上是操作符网络,是您拨打电话时使用的网络?

据我所知,每当我使用GPS时,蜂窝塔都会用来加速这个过程,这被称为AGPS.即使在设备上禁用无线,也会发生这种情况.

当您使用网络提供商时,它使用附近的无线网络,而不与蜂窝塔三角测量进行任何交互.为了实现这一目标,无线必须开启.

它是否正确?

解决方法

是的,它们与您拨打电话的网络相同.每个手机塔都有一个唯一的ID.

每个ID对应一个特定的位置.该位置的半径可以是几米到几千KM宽.

因此,您的AGPS获取塔ID,在数据库中查找,并且“我必须在xyz的2公里范围内”.这意味着它可以(粗略地)知道哪些GPS可能是开销,并相应地调整它们.

为了获得更好的准确性,手机可以查看几个塔的信号强度.如果到塔A的信号强于塔B – 它必须比A更接近A.

如果它可以看到3个或更多塔,它可以使用信号强度大致计算出它的位置.

最后,一些位置感知设备将使用WiFi来计算其位置.如果它知道WiFi网络“Starbuck-1234”在某条街道上,它可以使用该信息为您提供更精确的位置.

Android Animation Interpolator - Android 动画插值器分析

Android Animation Interpolator - Android 动画插值器分析

关于 TimeInterpolator

TimeInterpolator 是整个动画插值器的最顶层接口,只有一个方法,此处列出代码文件全文:

package android.animation;

/**
 * A time interpolator defines the rate of change of an animation. This allows animations
 * to have non-linear motion, such as acceleration and deceleration.
 */
public interface TimeInterpolator {
    /**
     * Maps a value representing the elapsed fraction of an animation to a value that represents
     * the interpolated fraction. This interpolated value is then multiplied by the change in
     * value of an animation to derive the animated value at the current elapsed animation time.
     *
     * @param input A value between 0 and 1.0 indicating our current point
     *        in the animation where 0 represents the start and 1.0 represents
     *        the end
     * @return The interpolation value. This value can be more than 1.0 for
     *         interpolators which overshoot their targets, or less than 0 for
     *         interpolators that undershoot their targets.
     */
    float getInterpolation(float input);
}

从注释来看,它的作用是「定义动画改变的速率,使得动画不一定要匀速改变,可以加速、减速。」
真实世界不总是匀速运转的,如果我们针对不同的场景采用合适的插值器,动画的表现会自然好看,从而为 App 增添色彩 ( ˇˍˇ )

问题是,插值器是怎么办到的?继续看注释。

插值器用一个 0~1.0 范围的浮点数表示当前动画播放的进度,0 代表开始播放,1.0 代表播放结束。通过 getInterpolation 把当前进度映射成另一个值。动画参照的时间由此被「篡改」,动画的速度由此被改变。

因此,我们可以这样理解插值器:把处于某个区间(有起点值和终点值)的一个值,按照某种算法,映射为另一个值。
Interpolator 汉语解释有两种:(1)【数学】内插器;分数计算器;(2)篡改者。印证了我们的理解。

接下来要思考的问题是,getInterpolation 是怎么被调用到的?要回答这个问题,我们必须回到 ValueAnimator 的源码:

关于 AnimationHandler

AnimationHandler 是 ValueAnimator 定义的一个静态内部类,它实现了一个 runnable,在内部维护一个计时循环(和 Choreographer 有关 TODO),从而产生计时脉冲(timing pulse),动画之所以能「动」,就是计时脉冲在起作用,可认为是动画的「心脏」,功能类似于单片机的晶振。

程序内所有动画共享同一个脉冲,使所有动画共享一个时间,以保证同步。每次脉冲发生时,每一个动画都会根据当前时间(对应@input)和 TimeInterpolator(对应 getInterpolation方法),计算出另一时间(对应 @return)。以下是函数调用栈(不完全):

// 内部维护一个 runnable,`Choreographer` 应该是维护计时循环的核心类,暂不深究了 TODO;
run();

// 总之这个函数会被定时调用到,它遍历所有的动画,决定把某个动画放入等待队列,还是从等待队列中取出来执行;
doAnimationFrame(long mChoreographer.getFrameTime());

// 如果某个动画处于激活状态,则这个函数会被调用到;
anim.doAnimationFrame(long frameTime)

// 然后调用到这个函数,上述函数调用中的 frameTime 被转换成了 currentTime,表示动画的当前时间;
animationFrame(long currentTime);
    // 这个算式很简单,根据动画时长、当前时间、开始时间,算出动画的播放进度,一个 0~1.0 范围的浮点数;
    float fraction = mDuration > 0 ?
        (float)(currentTime - mStartTime) / mDuration : 1f;

// 接下来的这个函数调用就很关键了,它的入口参数是动画的播放进度;
animateValue(float fraction);
    // 其一:通过 Interpolator 篡改播放进度;
    fraction = mInterpolator.getInterpolation(float fraction);
    // 其二:通过 TypeEvaluator 计算动画过程值,PropertyValuesHolder 是处理计算的核心类 TODO;
    mValues[i].calculateValue(fraction);
    // 其三:回调监听器,发出动画值改变的通知;
    mUpdateListeners.get(i).onAnimationUpdate(this);

再次强调两个关键类:Interpolator 和 TypeEvaluator

Interpolator.getInterpolation(float) 篡改了播放进度;
TypeEvaluator 拿着被篡改的进度计算当前的动画过程值 evaluate(float fraction, Object startValue, Object endValue)

这样,动画就可以忽快忽慢,或者全程加速,或者全程减速,或者是某种奇特的时间曲线。

TimeInterpolator 的「徒子徒孙」

TimeInterpolator 毕竟只是一个接口,没有任何具体实现,所以播放进度到底是如何被篡改的呢?请看它的「徒子徒孙」:

public interface TimeInterpolator {}
public interface Interpolator extends TimeInterpolator {}
abstract public class BaseInterpolator implements Interpolator {}
// 直接继承自 BaseInterpolator 的子类有:
AccelerateDecelerateInterpolator, AccelerateInterpolator, AnticipateInterpolator, AnticipateOvershootInterpolator, BounceInterpolator, CycleInterpolator, DecelerateInterpolator, LinearInterpolator, OvershootInterpolator, PathInterpolator

[AccelerateDecelerateInterpolator]

(http://grepcode.com/file/repository.grep...

这是默认的插值器,如果 setInterpolator(null) 则是线性插值器。(查阅API说明)
它的行为:开始和结尾减速、中间加速。(PS:和绳命的轨迹相似(绳命的幼年和老年、绳命的青年),这是成为默认插值器的理由,一个猜想,可能是对的。)
它的插值方法:

public float getInterpolation(float input) {
    return (float)(Math.cos((input + 1) * Math.PI) / 2.0f) + 0.5f;
}

什么?你说抽象?没关系,上图,插值方法对应的图形:

AccelerateDecelerateInterpolator

红线是我特意标注的,在 [0, 1] 范围内,开头和结尾斜率小,中间斜率大。也就是说,两头慢,中间快。

CycleInterpolator

CycleInterpolator 的插值方法:

public float getInterpolation(float input) {
    return (float)(Math.sin(2 * mCycles * Math.PI * input));
}

CycleInterpolator mCycles=1 时的图形:

clipboard.png

被篡改后的播放进度为负数是怎么回事?需要回到 getInterpolation(float) 方法,查看它对返回值的解释:

@return The interpolation value. This value can be more than 1.0 for interpolators which overshoot their targets, or less than 0 for interpolators that undershoot their targets.

[0, 1.0] 是未被篡改前的动画播放进度范围(即入口参数的范围),至于被篡改后的值,超过 1 被称为「过冲」,小于 0 被称为「下冲」

过冲和下冲目前我理解的也不是很清楚(TODO),所以还是看 GIF 图吧:

CycleInterpolator 的 GIF 效果图:

clipboard.png

从 ApiDemos 观察插值器的实际运行效果

这里只列出了两个插值器,还有很多很多,理解这些插值器的最好办法是观看它们的运行效果,修改参数再次观看运行效果。 ApiDemos 包含这样的代码:

ApiDemos/app/src/main/java/com/example/android/apis/view/Animation3.java

clipboard.png

附录

interpolation搜索自CNKI词典

1. 插值法、内插法、内推法、插入法 2. 插入、插入物 3. 窜改

~by central difference  中差插值法
~by continued fractions 用连分式的插值法
~by convergents         收敛插值法
~by propotionaI parts   比例插值法
~error                  内插误差
~error-filter           内插误差滤波器
~factor                 内插因子
~formula                插值公式
~functions              插值函数
~line                   内插行
~method                 内插法,插入法
~models                 插值模型
~of contours            等高线内插
~of gravity             重力内插
~oscillator             内插振荡器
~polynomial             插值多项式
~property               插入性质
~series                 插值级数
~set                    插入集[合]
~table                  内插表
~technique              插入法,间插法
~theory                 插值理论

来源:英汉科技大词库·第二卷 E-M

Google graph

clipboard.png

更多用法请查阅知乎问题 如何高效地使用搜索引擎?

相关博文

https://m.oschina.net/blog/137391
http://blog.kainaodong.com/?p=42
http://www.cnblogs.com/mengdd/p/3346003....

张大锤「Interpolator」语录

当代生活太慢了!必须提速了!纵身一跃!旁友们,以光速投身在星辰大海,必须让灵魂数位化了!生活太缓慢简直是犯罪,你今天洗了几个碗。2014-03-29

人,不要闹腾,躺着最好。存在的真谛是慢,让生活慢下来。和乌龟学习!(三姨夫生活感悟 2014-07-26

历法完全是个骗局,纯粹是统治阶级为了mindfuck人们的工具,个体对时间流逝的感知不同,怎么能一样算呢,比如老张时间过的慢,今年只有20岁,但按公历算已经45了,不公平!小刘12岁按公历算已经32了,这样男的放进学校能放心吗?建议取消历法,让生活模糊起来!就分以前和以后,保持时间的连续性 2015-11-19

星期日下午三点半,你突然决定从此刻起比别人慢一秒,太棒了!在所有精确的严丝合缝的必须的不容置疑的社会主义生活方式中猛的后撤,过一种慢一步的生活,你成功了,一些不知所措在你上方集中,你陌生化成功了,生活第一次输了 2016-01-17


版权声明:《Android Animation Interpolator - Android 动画插值器源码笔记》由 WeiYi.Li 在 2016年01月31日写作。著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
文章链接:http://li2.me/2016/01/android-animation-...

android emulator setting & configuation

android emulator setting & configuation

In order to make the Android emulator run faster and be more responsive, you can configure it to take advantage of hardware acceleration, using a combination of configuration options, specific Android system images and hardware drivers.


Using SDK manager to download/install x86 system image

1. Configuring Graphics Acceleration

Graphics acceleration for the emulator takes advantage of your development computer''s graphics hardware, specifically its graphics processing unit (GPU), to make screen drawing faster.


SDK Tool version >= 17

SDK Platform API version >= 15 (i.e. >= android 4.0.3)

In avd, specify "Use Host GPU", note not to specify snapshot

Plus, you can specify to use GPU acceleration (specify "-gpu on" in target''s additional emulator command line options) at runtime

2. Configuring Virtual Machine Acceleration

Caution: As of SDK Tools Revision 17, the virtual machine acceleration feature for the emulator is experimental; be alert for incompatibilities and errors when using this feature.

Many modern CPUs provide extensions for running virtual machines (VMs) more efficiently. Taking advantage of these extensions with the Android emulator requires some additional configuration of your development system, but can significantly improve the execution speed. Before attempting to use this type of acceleration, you should first determine if your development system’s CPU supports one of the following virtualization extensions technologies:

  • Intel Virtualization Technology (VT, VT-x, vmx) extensions

  • AMD Virtualization (AMD-V, SVM) extensions (only supported for Linux)

Note: Retina MAC Book Pro (i7-3635QM) supports VT


Note: Virtualization extensions are typically enabled through your computer''s BIOS and are frequently turned off by default. Check the documentation for your system''s motherboard to find out how to enable virtualization extensions.


To use virtual machine acceleration with the emulator, you need the following version of Android development tools. Use the Android SDK Manager to install these components:

  • Android SDK Tools, Revision 17 or higher

  • Android x86-based system image

Virtual machine acceleration on a Mac requires the installation of the Intel Hardware Accelerated Execution Manager (Intel HAXM) kernel extension to allow the Android emulator to make use of CPU virtualization extensions. 

  • Configuring VM Acceleration on Mac

    To install the Intel HAXM kernel extension:

    1. Start the Android SDK Manager, select 

      Extras 

      and then select 

      Intel Hardware Accelerated Execution Manager.

    2. After the download completes, execute 

      /extras/intel/Hardware_Accelerated_Execution_Manager/IntelHAXM.dmg.

    3. Double click the 

      IntelHAXM.mpkg 

      icon to begin installation.

    4. Follow the on-screen instructions to complete installation.


    5. After installation completes, confirm that the new kernel extension is operating correctly by opening a terminal window and running the following command:


    6. kextstat | grep intel

    7. You should see a status message containing the following extension name, indicating that the kernel extension is loaded:

    8. com.intel.kext.intelhaxm


    9. Restart ECLIPSE

    10. recreate avd to "Use Host GPU" in x86 system image

    11. start avd



Android java.lang.ClassCastException:无法将android.widget.RelativeLayout强制转换为android.widget.EditText

Android java.lang.ClassCastException:无法将android.widget.RelativeLayout强制转换为android.widget.EditText

单击按钮将我从一个活动带到另一个活动时,我在Android中收到以下异常(我是Android开发中的新手,因此可能不是最聪明的问题):

java.lang.classCastException: android.widget.RelativeLayout cannot be cast to android.widget.EditText

我试过几次清理项目,尝试过Android Tools中的Fix Project Properties选项,已经检查了xml中的错误,但似乎无法弄清楚.我不得不提到,在发生此异常之前,该按钮可以正常工作一段时间.

这是我的xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/editCustomerPhone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_dark"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".CustomerInfoActivity" >

<FrameLayout
    android:id="@+id/frameLayout1"
    android:layout_width="wrap_content"
    android:layout_height="250dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:background="@drawable/ic_new_delivery" >

    <TextView
        android:id="@+id/textView2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Insert Customer Data:"
        android:textColor="@color/light_blue"
        android:textSize="20sp"
        android:text/>

</FrameLayout>

<EditText
    android:id="@+id/editCustomerName"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/textView1"
    android:layout_alignBottom="@+id/textView1"
    android:layout_alignParentRight="true"
    android:ems="10"
    android:inputType="textPersonName"
    android:textColor="@color/light_blue" />

<Button
    android:id="@+id/submitInfoBtn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView1"
    android:layout_alignParentBottom="true"
    android:layout_alignRight="@+id/editCustomerName"
    android:text="Submit Info"
    android:textColor="@color/light_red" 
    android:onClick="submitCustomerInfo"/>

<EditText
    android:id="@+id/editCustomerPhone"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/editCustomerName"
    android:layout_alignParentRight="true"
    android:layout_alignTop="@+id/TextView01"
    android:ems="10"
    android:inputType="phone"
    android:textColor="@color/light_red" >

    <requestFocus />
</EditText>

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/frameLayout1"
    android:text="Name:"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@android:color/background_light"
    android:textandroid:typeface="serif" />

<TextView
    android:id="@+id/TextView02"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/editCustomerPhone"
    android:layout_marginTop="14dp"
    android:text="Email:"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@android:color/background_light"
    android:textandroid:typeface="serif" />

<EditText
    android:id="@+id/editCustomerEmail"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/TextView02"
    android:layout_alignBottom="@+id/TextView02"
    android:layout_alignLeft="@+id/editCustomerPhone"
    android:layout_alignParentRight="true"
    android:ems="10"
    android:inputType="textEmailAddress"
    android:textColor="@color/light_green" />

<TextView
    android:id="@+id/TextView01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/TextView02"
    android:layout_below="@+id/editCustomerName"
    android:layout_marginTop="19dp"
    android:text="Phone:"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@android:color/background_light"
    android:textandroid:typeface="serif" />
@H_301_17@

这是我在活动中引发异常的onCreate方法:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_customer_info);

    this.editMail = (EditText)findViewById(R.id.editCustomerEmail);
    this.editName = (EditText)findViewById(R.id.editCustomerName);
    this.editPhone = (EditText)findViewById(R.id.editCustomerPhone); // the exception points me here
}
@H_301_17@

解决方法:

您的代码说:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/editCustomerPhone"
@H_301_17@

editCustomerPhone是相对布局.

android MediaPlayer NullPointerException

android MediaPlayer NullPointerException

我有点难以对此进行故障排除,因为我是通过其他人的 Android设备的崩溃报告得到的,我无法向他们提问,而且我从未在自己的Android设备上看到它.

崩溃报告说它是Android 4.1.2,堆栈跟踪是:

java.lang.NullPointerException
at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:2102)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5021)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)

不幸的是,grepcode.com上的android源代码似乎与这些行号不匹配,所以我不确定哪个是null.

当发生这种情况时,我不知道用户正在做什么,所以我不知道这是在音乐或声音效果正在播放时发生,还是在发生破坏时发生了什么.我有点怀疑它可能在毁灭期间发生.我在activity的onDestroy方法中有以下代码:

public void onDestroy() {
    synchronized(curPlayers) {
        for(List<MediaP> ms : curPlayers.values()) {
            synchronized(ms) {
                for(MediaP m : ms) {
                    synchronized(m) {
                        m.m.stop();
                        m.m.release();
                    }
                }
            }
        }
        curPlayers.clear();
    }
}

private static class MediaP {
    private MediaP(MediaPlayer m) {
        this.m = m;
    }

    private MediaPlayer m;
    private boolean wasplaying = false;
}

那里有什么我应该做的吗?

解决方法

在release()之前删除对MediaPlayer.stop()的调用.我们在Nexus 4,5,7,10和Moto X上看到过很多类似的崩溃.你可以在这里阅读更多内容 NullPointerException in MediaPlayer$EventHandler.handleMessage

据我所知,有一次他们切换到从stop()发送消息,如果你不够运气,你的release()会在检查到它不为空并尝试调用其方法后立即使对象无效.

关于android – 什么时候使用了cell tower triangulation?android什么时候出来的的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于Android Animation Interpolator - Android 动画插值器分析、android emulator setting & configuation、Android java.lang.ClassCastException:无法将android.widget.RelativeLayout强制转换为android.widget.EditText、android MediaPlayer NullPointerException等相关内容,可以在本站寻找。

本文标签: