I am creating an indoor navigation app. I am using RSSI value of wifi for navigation. The problem is: How can I move the imageview with red spot when the value of RSSI changes?
My work so far:
ImageView iv1; //map image
ImageView iv2; //red spot
TextView tv1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
this.registerReceiver(this.myRssiChangeReceiver,
new IntentFilter(WifiManager.RSSI_CHANGED_ACTION));
iv1=(ImageView)findViewById(R.id.imageView1);
iv2=(ImageView)findViewById(R.id.imageView2);
tv1=(TextView)findViewById(R.id.textView1);
}
private BroadcastReceiver myRssiChangeReceiver
= new BroadcastReceiver(){
@Override
public void onReceive(Context arg0, Intent arg1) {
// TODO Auto-generated method stub
int newRssi = arg1.getIntExtra(WifiManager.EXTRA_NEW_RSSI, 0);
//result.setText(String.valueOf(newRssi));
tv1.setText(String.valueOf(newRssi));
}};
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
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="com.smshah.indoormap.MainActivity" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="@drawable/uit_floor_plan" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/loc_ptr" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textAppearance="?android:attr/textAppearanceSmall" />
Try looking at examples for animation like this. I think the LinearInterpolator would be the way to go if you could tie it to your location change event and update the from - to coordinates.
EDIT: Look into this TranslateAnimation sample. That may be more helpful to you.