android-sdk-2.1

How to calculate distance using coordinates from LocationManager

谁都会走 提交于 2020-01-17 04:49:07
问题 I am using LocationManager to get the values of Latitude and Longitude of a user. These values are updated regularly to a database. Now, i want to find out the distance between two users basing on the stored Latitude and Longitude values. I want to display a message when distance between two users is less than (say 100 meters). Can anyone please guide me with a tutorial or some sample code of how to achieve it. 回答1: You can have a look at the Location class. You can set the longitude and

Issue using Contact Group delete on Android

旧时模样 提交于 2020-01-11 04:05:09
问题 I have this code to delete a Contact Group public void delete(Activity act,String[] args) { try { int b=act.getContentResolver().delete(ContactsContract.Groups.CONTENT_URI,"_ID=?", args); Toast.makeText(act, "Deleted",Toast.LENGTH_SHORT).show(); //notify registered observers that a row was updated act.getContentResolver().notifyChange(ContactsContract.Groups.CONTENT_URI, null); } catch (Exception e) { Log.v(TAG, e.getMessage(), e); Toast.makeText(act, TAG + " Delete Failed",Toast.LENGTH_LONG)

Buttons inside TAB not clickable/responding

被刻印的时光 ゝ 提交于 2020-01-06 08:41:41
问题 I have done TABS in my app using TabHost. one of the tabs has two buttons in it("button","anotherButton") After I run my app I can see both tabs, but when I press on them nothing happens(they aren't even "clickable" when I press them.) And moreover, they don't respond to any listeners which I add to them. Some code: main.xml: <?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tabhost" android:layout_width="fill_parent"

1.6 to 2.1 CameraInfo alternative?

耗尽温柔 提交于 2019-12-25 02:22:27
问题 android.Camera.Preferences.setRotation documentation public void onOrientationChanged(int orientation) { if (orientation == ORIENTATION_UNKNOWN) return; android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); android.hardware.Camera.getCameraInfo(cameraId, info); orientation = (orientation + 45) / 90 * 90; int rotation = 0; if (info.facing == CameraInfo.CAMERA_FACING_FRONT) { rotation = (info.orientation - orientation + 360) % 360; } else { // back-facing camera

Android: NullPointerException on getWritableDatabase()

萝らか妹 提交于 2019-12-24 03:23:42
问题 Here is where I try to access the database: UserDataAdapter dbHelper = new UserDataAdapter(this); dbHelper.open(); dbHelper.createNetwork(network); dbHelper.close(); UserDataAdapter.java: public UserDataAdapter open() throws SQLException { dbHelper = new DatabaseHelper(context); // of class DatabaseHelper database = dbHelper.getWritableDatabase(); // this line!! return this; } DatabaseHelper.java: public DatabaseHelper(Context context) { super(context, Defines.DATABASE_NAME, null, Defines

AvoidXferMode Tolerance

风格不统一 提交于 2019-12-24 03:14:11
问题 I have a problem with the following code: protected void onDraw(Canvas canvas) { Paint paint = new Paint(); // Draw a blue circle paint.setColor(Color.BLUE); canvas.drawCircle(100, 100, 50, paint); // Draw a red circle where it collides with the blue one paint.setXfermode(new AvoidXfermode(Color.BLUE, 0, Mode.TARGET)); paint.setColor(Color.RED); canvas.drawCircle(50, 50, 50, paint); } According to the API documentation of AvoidXfermode the tolerance value 0 means that it looks for an EXACT

Android: Camera Preview Orientation on HTC EVO (Android 2.1 or 2.2)

旧城冷巷雨未停 提交于 2019-12-23 03:26:20
问题 I am developing an Android application that relies on the camera API, using an HTC EVO as my testing device. No matter what I've tried so far, the only time the camera preview looks right is in landscape mode (90 degrees rotation, to be specific). It seems as though there is no way to orient the preview correctly when in portrait mode (0 degrees rotation). The default camera application on the device (for HTC Sense) allows for any kind of rotation without any problem, so I know that there is

Viewflipper Receiver not registered error while orientation change in 2.1 and 2.2

为君一笑 提交于 2019-12-22 08:13:54
问题 I am using viewflipper for fling gesture recognition everything works fine for 2.0 and prior but in 2.2 and 2.1 it throws exception as "java.lang.IllegalArgumentException: Receiver not registered: android.widget.ViewFlipper" below is full debug trace. java.lang.IllegalArgumentException: Receiver not registered: android.widget.ViewFlipper$1@452f8398 09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.app.ActivityThread$PackageInfo.forgetReceiverDispatcher(ActivityThread.java:793) 09-19

Regarding removal of Activity Title bar in Android

青春壹個敷衍的年華 提交于 2019-12-22 05:41:47
问题 i have already set the theme of my activity as android:theme = "@android:style/Theme.Dialog" but i also want to remove the title bar of the activity. so how to use android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" along with the dialog theme. 回答1: Try creating a custom style that extends Theme.Dialog : <resources> <style name="DialogNoTitle" parent="android:Theme.Dialog"> <item name="android:windowNoTitle">true</item> </style> </resources> 回答2: I believe you can specify this in

Is there an easy way to “deactivate logging” prior to releasing your app on the market?

送分小仙女□ 提交于 2019-12-20 23:29:07
问题 I'm preparing to release an app on the market place, on reading the Google documentation located here it suggests the following : Deactivate any calls to Log methods in the source code. Is there an easier way than having to go through all my source files and remove each line manually? Also, why remove the logging, is it a resource hog? 回答1: You can do this through proguard. In the latest SDK and tools a proguard configuration file should already exist. Christopher answered this in a similar