Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

October 12, 2012

[SOLVED] Android. Get Signing certificate fingerprint (SHA1)

While creating the Client ID in the Google APIs Console you will be asked for
"Signing certificate fingerprint (SHA1):"

to obtain this fingerprint just run:
keytool -list -alias temp -keystore /path/to/your/keystore_file
you will be asked fot password and the Certificate fingerprint (SHA1) will be shown


"keytool comes with the Java SDK. You should find it in the directory that contains javac, etc."
via http://stackoverflow.com/a/2998451/47399 


August 3, 2012

[SOLVED]Connect Nexus 7 and/or Galaxy Nexus to ubuntu

You want to develop on your new shiny Nexus 7 and
adb devices

keeps giving you
???????? device

oprn your rules file
gksu gedit /etc/udev/rules.d/51-android.rules

probably you will see following line (if you already configured your Galaxy nexus) If not add it to the file, just in case
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="YOUR_USER_ID"

Now we should get the idVendor and idProduct from the Nexus 7. Connect it to your computer and
lsusb

you will see something like
Bus 001 Device 013: ID 18d1:4e42 Google Inc.

we need this two values

paste this string with proper values to 51-android.rules
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e42", MODE="0666", OWNER="YOUR_USER_ID"

Save the file. Do the
sudo service udev restart

Now run
adb devices

you should see your device
List of devices attached
015d172c98280c0b device

Happy developing

Source: http://govfate.iteye.com/blog/1608379

June 8, 2012

[SOLVED] Android: Samsung Galaxy Tab 10.1 on Ubuntu

Just follow this tutorial http://forum.xda-developers.com/showthread.php?t=1077377

My 64bit RULES FILE:
ACTION!="add", GOTO="gtab_rules_end"
SUBSYSTEM!="usb|usb_device", GOTO="gtab_usb_end"

ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="685e", MODE="0777" SYMLINK+="gtab"

LABEL="gtab_usb_end"

LABEL="gtab_rules_end"

April 27, 2011

[SOLVED] ReConnect Eclipse to Android emulator

Just run these command in your console

adb kill-server
adb connect <%TARGET_PC_IP_OR_HOSTNAME%>:<%EMULATOR_PORT%>


for emulator on my pc it was
adb kill-server
adb connect localhost:5555

Source: stackoverflow.com

February 16, 2011

January 23, 2011

[SOLVED] Android: Set dynamically textview height


TextView tv = (TextView) findViewById(R.id.TextView01);
final int height_in_pixels = tv.getLineCount() * tv.getLineHeight()
* getResources().getDisplayMetrics().density;
//approx height text
tv
.setHeight(height_in_pixels);

Solved: stackoverflow.com

[SOLVED] Android: Override back button


@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
   
if (keyCode == KeyEvent.KEYCODE_BACK) {
        //do some stuff

       
return true;
   
}
   
return super.onKeyDown(keyCode, event);
}

 

Source: stackoverflow.com.

January 12, 2011

[SOLVED] Android: Handling gzipped content while downloading

On file download you can check the content type and if its gzipped - unzip it on the fly:

URLConnection connection = url.openConnection();
InputStream stream = connection.getInputStream();
if ("gzip".equals(connection.getContentEncoding())) {
stream = new GZIPInputStream(stream));
}


Source: stackoverflow.com

January 9, 2011

[SOLVED] Android: Get an string array from an array.xml resource

Here you can see how to retrieve values from array.xml
Log.i("test",getImageQualityAsString(1));

array.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="image_export_list_preference">
<item>480x320</item>
<item>800x480</item>
<item>1024x768</item>
</string-array>
<string-array name="entryvalues_image_export_list_preference">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
</resources>

Function:
private String getImageQualityAsString(int sizeItem){

try {
String[] bases = getResources().getStringArray(R.array.image_export_list_preference);

return bases[sizeItem];

} catch (Exception e) {
return "";
}

}

Source: stackoverflow.com

December 25, 2010

[SOLVED] Android: no adb on Suse linux or "???????????? no permissions"

You cant develop on your linux pc because you are getting something like this.
$ adb devices
List of devices attached
???????????? no permissions

temporary solution - to restart adb server as root
$ su
$ adb kill-server
$ adb start-server
$ adb devices

add your device to devices list.
1) check your vendor ID
$ lsusb
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 044: ID 18d1:2d66 <- this is my mobile
Bus 002 Device 004: ID 0451:2046 Texas Instruments, Inc. TUSB2046 Hub
Bus 002 Device 003: ID 10d5:0001 Uni Class Technology Co., Ltd

In my case , for Nexus One, it is 18d1

2) now add lines in to "/etc/udev/rules.d/51-android.rules"
$ su
$ vim /etc/udev/rules.d/51-android.rules

now paste these lines with your values
SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"
SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", OWNER="%YOUR_USER%" GROUP="%YOUR_USER_GROUP%"

save your file.

now it should work...

Source: google.com

December 13, 2010

[SOLVED] Android: Multiple substitutions specified in non-positional format

Getting an error after updating to SDK 0.8
Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute? strings.xml

It happens in string files on strings with %
	"%s/%s (Linux; Android)"

You should change it to
	"%1$s/%2$s (Linux; Android)"

Source: developer.android.com

November 21, 2010

[SOLVED] How can i call Wi-Fi settings screen from my App

To start wifi settings dialog:
startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));

to start Settings Dialog
startActivity(new Intent(Settings.ACTION_SETTINGS));

to start any settings dialog read the reference

Source: stackoverflow.com

Reference: http://developer.android.com/reference/android/provider/Settings.html

[SOLVED] How to create Alert Dialog?

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure you want to exit?")
       .setCancelable(false)
       .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) {
                MyActivity.this.finish();
           }
       })
       .setNegativeButton("No", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
           }
       });
AlertDialog alert = builder.create();
alert.show();

Source: developer.android.com

[SOLVED] How to check internet access on Android?

You can use
Context.getSystemService(Context.CONNECTIVITY_SERVICE).getNetworkInfo(ConnectivityManager.TYPE_MOBILE)

or
Context.getSystemService(Context.CONNECTIVITY_SERVICE).getNetworkInfo(ConnectivityManager.TYPE_WIFI)

and parse the DetailedState enum of the returned NetworkInfo object

 

and don't forget to allow it the Manifest

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

 

Source: stackoverflow.com

Documentation: http://developer.android.com/reference/android/net/ConnectivityManager.html

November 20, 2010

[SOLVED] Android: When the soft keyboard pops up, the EditText is invisible

Just add android:windowSoftInputMode="adjustPan" for your activity in manifest file
<activity android:name="SampleActivity" android:label="@string/app_name" android:windowSoftInputMode="adjustPan" >
...
</activity>

Source: stackoverflow.com

Documentation: http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft
Tutorial: http://android-developers.blogspot.com/2009/04/updating-applications-for-on-screen.html

November 16, 2010

[SOLVED] Android - Arrange two buttons next to each other and to center them horizontally.

Arrange two buttons next to each other and to center them horizontally.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="horizontal"
    android:background="@android:drawable/bottom_bar" android:paddingLeft="4.0dip"
    android:paddingTop="5.0dip" android:paddingRight="4.0dip"
    android:paddingBottom="1.0dip" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_below="@+id/TextView01">
    <Button android:id="@+id/allow" android:layout_width="0.0dip"
        android:layout_height="fill_parent" android:text="Allow"
        android:layout_weight="1.0" />
    <Button android:id="@+id/deny" android:layout_width="0.0dip"
        android:layout_height="fill_parent" android:text="Deny"
        android:layout_weight="1.0" />
</LinearLayout>

 

Source: stackoverflow.com

November 15, 2010

August 26, 2010

install app to sd card in 2.2 (froyo)

-Go here
--http://developer.android.com/sdk/index.html
and get the SDK for your OS
-Once you download it, unzip it to its own folder, I put it off C:\
-Run the SDK Setup.exe
-Click available Packages, on left, I didn't know what was needed so I installed -EVERYTHING. Although I do suspect that we only need the USB driver, which is at the very bottom.
It will take forever to install.
After it's done installing, I Clicked on Installed Packages, and updated all.


Not done yet.
check that the phone is set up to allow debugging via USB (Settings⇒Applications⇒Development⇒USB debugging)
Plug in your phone
Windows will fail to install the driver.
Go in device manager and and update the newly Yellowed entry, the driver is in:
C:\android-sdk_r06-windows\android-sdk-windows\usb_driver
The driver should install

Start console: "Start"->"Run"->cmd->ENTER

> adb devices
if you see a serial number starting with an "H" that means you got things working, now do the following:
adb shell pm setInstallLocation 2

This command will push ALL apps to your sd card, to revert back to saving apps to internal memory enter in:


adb shell pm setInstallLocation 0

Source: install app to sd card in 2.2 (froyo)

July 18, 2010

[SOLVED]Market Slowness and Accessibility on cyanogenmod's CM6 RC1

After upgrading to the latest Cyanogen I notices, that the Android Market is quiet slow and does not show my downloaded apps in the download section. 2 Fixes to repair this:

1) Take the following source and save in file named vending_preferences.xml

<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<boolean name="local_db_sync_required" value="false" />
<int name="SERVER_VERSION" value="1000" />
<string name="vending_tos_version">1.0.0</string>
<long name="MARKET_LAST_HEARTBEAT_TIMESTAMP" value="1271657433127" />
<long name="last_sync_time" value="1271659724720" />
<long name="last_tickle_id" value="1271657514775" />
<int name="reconciled_version" value="1710" />
<boolean name="metadata_paid_apps_enabled" value="true" />
<string name="vending_backup_state">vending</string>
<string name="vending_tos_version">1.0.0</string>
</map>

Now push to /data/data/com.android.vending/shared_prefs/vending_preferences.xml :

adb push vending_preferences.xml /data/data/com.android.vending/shared_prefs/vending_preferences.xml

Next you do in a terminal window (device or via adb shell):

su
cd /data/data/com.android.vending/cache
rm *
reboot

Source: MattiDroid - Mobile Blog: N1/G1: Market Slowness and Accessibility.

July 17, 2010

[SOLVED]How customize/extend/ Spinner

You will need to take control over what goes into the ListView and
Spinner. I have not experimented with these techniques on Spinner, but
on ListView, you will need to override getView() (on ArrayAdapter) or
newView() and bindView() (on CursorAdapter).
Here is a free excerpt from one of my books that demonstrates the technique:

http://commonsware.com/Android/excerpt.pdf

In your case, you would use your Typeface object to update the font used
by the TextView widgets in your rows.

In principle, you could do this via a wrapping adapter -- this would be
more reusable but a bit slower. I have an AdapterWrapper base class here:

http://github.com/commonsguy/cwac-adapter

and some projects that use it here:

http://github.com/commonsguy/cwac-endless
http://github.com/commonsguy/cwac-thumbnail


You also need to override getDropDownView().

Source: How to change the Typeface of ListView and Spinner - Android Beginners Google Groups.