Sunday, April 28, 2013

[android help] How to align view elements in Relativelayout dynamically through code in Android?



layout.addView(cb1);

lp.addRule(RelativeLayout.BELOW,cb1.getId());
cb2.setLayoutParams(lp);
layout.addView(cb2);

lp.addRule(RelativeLayout.BELOW,cb2.getId());
cb3.setLayoutParams(lp);
layout.addView(cb3);


Thanks man this helped me a lot


I guess you are wrong at the point that you are using "lp" as the layout parameters for both cb2 and cb3(you can't add the same rule "RelativeLayout.BELOW" to same layoutparameters object "lp" again and again). Use lp for cb2 and lp2 for cb3 and create like this



RelativeLayout layout = new RelativeLayout(this);

CheckBox cb1 = new CheckBox(this);
cb1.setId(1);
cb1.setText("A");

CheckBox cb2 = new CheckBox(this);
cb2.setId(2);
cb2.setText("B");

CheckBox cb3 = new CheckBox(this);
cb3.setId(3);
cb3.setText("C");

RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout.setLayoutParams(lp);

layout.addView(cb1);

lp.addRule(RelativeLayout.BELOW,cb1.getId());
cb2.setLayoutParams(lp);
layout.addView(cb2);

RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);//important

lp2.addRule(RelativeLayout.BELOW,cb2.getId());//important
cb3.setLayoutParams(lp2);//important
layout.addView(cb3);


I think this will work.



.

stackoverflow.comm

[android help] Storing and accessing large tables of static information


I am writing an Android application that reads data from legacy devices, and presents it to the user. Much of this data consists of 16-bit enumerations that represent things like device information, status, errors, etc... There are over 100 of these enumerations.


In the past, the user would have to look up the returned value in a large binder of tables. For example, let's say the device returns an error as 0xFE04. There's some row in some table like this...



+--------+-------------------+------------------+----------+--------------------+
| Code | Short Description | Long Description | Solution | Alternate Solution |
+--------+-------------------+------------------+----------+--------------------+
| 0xFE04 | blah | blahblah | blah | blahblah |
+--------+-------------------+------------------+----------+--------------------+


How can I store these tables in code so that I can return all this information to the user efficiently & effectively.


This may have to be ported in the future for iOS or even windows, so a more language-independent solution is preferred.



.

stackoverflow.comm

[android help] On Google TV How do I make Fullscreen Activity hide title and button properly?

android - On Google TV How do I make Fullscreen Activity hide title and button properly? - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















It would seem that the Fullscreen Activity Demo/Template does not behave the same on Google TV with the way Status/Navigation/Action bar are handled. Note: to make the default template work on Honeycomb I had to make a slight change to the provided SystemUiHiderHoneycomb class (details)


Question: Should the Template work properly? (I think yes). Is there a good way of fixing it without special handling for Google TV detection? What's a good way of achieving the same result of hiding the title at the top and the button at the bottom?


Steps to reproduce:


  1. Create new application via Android Tools wizard

  2. Use Fullscreen Activity as first and only activity

  3. perform code modification to SystemUiHiderHoneycomb class (details)

I tested this on a Google TV emulator and on a real device with the same result. (I also tested it without the change in step 3).


Screenshot of default Fullscreen Activity



















Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.










default






.

stackoverflow.comm

[android help] SQLite excpetion unable to convert BLOB to string

android - SQLite excpetion unable to convert BLOB to string - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















In my android project I fetch one problem during retrieving data from data base. In this I try to get String value from DB like URL but when this code execute then I get this error android.database.sqlite.SQLiteException: unknown error: Unable to convert BLOB to string And only URL colomn give me this error not any other string colomn.


I didn't get where I am wrong. So friend please give me suggestion how I can resolve this problem. Here I also print my LogCat.


Thank You.



08-22 20:08:12.290: WARN/System.err(10844): android.database.sqlite.SQLiteException: unknown error: Unable to convert BLOB to string
08-22 20:08:12.300: WARN/System.err(10844): at android.database.CursorWindow.getString_native(Native Method)
08-22 20:08:12.300: WARN/System.err(10844): at android.database.CursorWindow.getString(CursorWindow.java:329)
08-22 20:08:12.300: WARN/System.err(10844): at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:49)
08-22 20:08:12.300: WARN/System.err(10844): at com.catLog.ProductsDetailsHomeTab.getProductDeatilsFromDB(ProductsDetailsHomeTab.java:337)
08-22 20:08:12.300: WARN/System.err(10844): at com.catLog.ProductsDetailsHomeTab.setFlipperChild1(ProductsDetailsHomeTab.java:201)
08-22 20:08:12.300: WARN/System.err(10844): at com.catLog.Widget.ViewFlipper_ProductDetails.onRightToLeftSwipe(ViewFlipper_ProductDetails.java:68)
08-22 20:08:12.300: WARN/System.err(10844): at com.catLog.Widget.ViewFlipper_ProductDetails.onTouchEvent(ViewFlipper_ProductDetails.java:131)
08-22 20:08:12.300: WARN/System.err(10844): at android.view.View.dispatchTouchEvent(View.java:3766)
08-22 20:08:12.300: WARN/System.err(10844): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:897)
08-22 20:08:12.300: WARN/System.err(10844): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
08-22 20:08:12.300: WARN/System.err(10844): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
08-22 20:08:12.300: WARN/System.err(10844): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1676)
08-22 20:08:12.300: WARN/System.err(10844): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1112)
08-22 20:08:12.300: WARN/System.err(10844): at android.app.Activity.dispatchTouchEvent(Activity.java:2086)
08-22 20:08:12.300: WARN/System.err(10844): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1660)
08-22 20:08:12.300: WARN/System.err(10844): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
08-22 20:08:12.300: WARN/System.err(10844): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
08-22 20:08:12.300: WARN/System.err(10844): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1676)
08-22 20:08:12.300: WARN/System.err(10844): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1112)
08-22 20:08:12.300: WARN/System.err(10844): at android.app.Activity.dispatchTouchEvent(Activity.java:2086)
08-22 20:08:12.300: WARN/System.err(10844): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1660)
08-22 20:08:12.300: WARN/System.err(10844): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
08-22 20:08:12.300: WARN/System.err(10844): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
08-22 20:08:12.300: WARN/System.err(10844): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
08-22 20:08:12.300: WARN/System.err(10844): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
08-22 20:08:12.300: WARN/System.err(10844): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
08-22 20:08:12.300: WARN/System.err(10844): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1676)
08-22 20:08:12.300: WARN/System.err(10844): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1112)
08-22 20:08:12.300: WARN/System.err(10844): at android.app.Activity.dispatchTouchEvent(Activity.java:2086)
08-22 20:08:12.300: WARN/System.err(10844): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1660)
08-22 20:08:12.300: WARN/System.err(10844): at android.view.ViewRoot.handleMessage(ViewRoot.java:1785)
08-22 20:08:12.300: WARN/System.err(10844): at android.os.Handler.dispatchMessage(Handler.java:99)
08-22 20:08:12.300: WARN/System.err(10844): at android.os.Looper.loop(Looper.java:123)
08-22 20:08:12.300: WARN/System.err(10844): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-22 20:08:12.300: WARN/System.err(10844): at java.lang.reflect.Method.invokeNative(Native Method)
08-22 20:08:12.300: WARN/System.err(10844): at java.lang.reflect.Method.invoke(Method.java:521)
08-22 20:08:12.300: WARN/System.err(10844): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
08-22 20:08:12.300: WARN/System.err(10844): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
08-22 20:08:12.300: WARN/System.err(10844): at dalvik.system.NativeStart.main(Native Method)




























How to convert BLOB to string?



Direct conversion is not possible without using some UDF, but you can extract text using SUBSTRING function:



What is the datatype of the column you are getting the error on (from what you say I think this is the URL column)? Sounds like it is of type BLOB which is a representation of an image but not a string








































lang-sql






.

stackoverflow.comm

[android help] How can I detect current device is Android Tablet?


Your Galaxy Tab is running Honeycomb or higher, which means that the old Options Menu has been deprecated in favor of Action Bar. That having been said, there's still a menu icon in the title bar (a square with a slash through it in Honeycomb and three square dots in Jelly Bean). If your user clicks that, they get your standard options menu (without menu item icons, however).


The alternative is to run ActionBar Sherlock to give your apps action bars, regardless of OS version.


If you insist on doing your own branching based on OS version, try this:



int sdk = android.os.Build.VERSION.SDK_INT;

if(sdk < android.os.Build.VERSION_CODES.HONEYCOMB)
{
// Gingerbread and earlier
}
else
{
// Honeycomb and later
}


.

stackoverflow.comm

[android help] HTC One X+ Home Sence Launcher won't let me clear defaults programmatically


I want to show Settings->Applications->Manage Applications-> home launcher application ->'Clear Defaults' programmatically in my application.This works fine in all devices except HTC One X+.


In HTC One X+, 'Home Sence' application is set as default home launcher.When i tried to set my application as home launcher this shows Resolver Dialog too.


In my application i want to clear the default settings of current home launcher application and set mine as home launcher.So,I tried this code



Intent intent = new Intent();
final int apiLevel = Build.VERSION.SDK_INT;
if (apiLevel >= 9) { // above 2.3
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", packageName, null);
intent.setData(uri);
} else {
// below 2.3
String appPkgName = (apiLevel == 8 ? "pkg" : "com.android.settings.ApplicationPkgName");
intent.setAction(Intent.ACTION_VIEW);
intent.setClassName(APP_DETAILS_PACKAGE_NAME, APP_DETAILS_CLASS_NAME);
intent.putExtra(appPkgName, packageName);
}
this.startActivity(intent);


But it won't let me show the 'Clear Defaults' of HTC Sence.It works for any other application on this device.What is the problem here? Why 'HTC Sence' won't let me to clear defaults?How can i fix this?


Thanks in Advance



.

stackoverflow.comm

[android help] Android Creating Output Files To Extract Them From PC

java - Android Creating Output Files To Extract Them From PC - Stack Overflow








Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















I am trying to make an android app that will create some records in simple text files such that a computer can access those file. I think I understand the process of creating and writing files internally but I can't find these files with the computer when I connect it through USB or an app such as AirDroid. My initial intention was to put the file in a folder (maybe the root folder) which would allow me to grab that information from my personal computer. Is such thing even possible? If it is not, is there an alternative way of accessing the files created by my app? Thanks for your help.
















Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.










lang-java







.

stackoverflow.comm

[android help] Cannot be resolved to a type: Error


I am getting this error: ShowDialog cannot be resolved to a type


Here is my code:



final CharSequence[] items = {"Low", "Medium", "High"};

AlertDialog.Builder builder = new AlertDialog.Builder(ShowDialog.this);
builder.setTitle("Alert Dialog with ListView");
builder.setIcon(R.drawable.image1);
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
}
});
AlertDialog alert = builder.create();

alert.show();


Any ideas why I am getting this annoying error? I have tried to refresh my code and also clean it and still no luck. Thanks



.

stackoverflow.comm

[android help] Android Search Using Fragments

Android Search Using Fragments - Stack Overflow








Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















I need to do an android search using fragments and have been looking at this: Android search with Fragments


I have a couple of questions, however, regarding the 1st answer.


I do not want a new page to pop up; I want the search results to be populated within a listview of the current fragment I am within. Is that possible?


I'm not sure what code to write after:



/**
* Performs a search and passes the results to the container
* Activity that holds your Fragments.
*/

public void doMySearch(String query) {
// TODO: implement this
}


How do I pass my results to a 'container activity' that holds my fragments? Would that be my MainActivity (that's where the code of all my fragments is located)?


























'Container Activity' doesn't specifically your MainActivity as this is the name a lot of devs and example code gives to their landing/home activity.


'Container Activity' refers to the Activity to which your ListView (ListFragment?) and Search Fragment belong.


To post the results (via your TODO code), get the parent Activity (getActivity()) and implement a method on the parent Activity that gets the fragment with the ListView and passes the data to it. You may want to have a method on the ListView that handles this rather than putting it on the Activity. (I like to think of a parent Activity as a delegator)




















default







.

stackoverflow.comm

[android help] NullPointerException with fragments


My application contains ViewPager in MainActivity with two fragments. First fragment contains ListView. I never see this, but I see reports from users about RuntimeException in Google Play:



java.lang.RuntimeException: Unable to resume activity {com.my.project/com.my.project.MainActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { (has extras) }} to activity {com.my.project/com.my.project.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2120)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2135)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1668)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:875)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:633)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { (has extras) }} to activity {com.my.project/com.my.project.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.deliverResults(ActivityThread.java:2532)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2107)
... 12 more
Caused by: java.lang.NullPointerException
at com.my.project.FirstFragment.load(FirstFragment.java:551)
at com.my.project.MainActivity.onActivityResult(MainActivity.java:132)
at android.app.Activity.dispatchActivityResult(Activity.java:3908)
at android.app.ActivityThread.deliverResults(ActivityThread.java:2528)
... 13 more


Here is code from FirstFragment.java:



public class FirstFragment extends Fragment {

ArrayList listItems = null;
ArrayAdapter mAdapter;

void load() {
mAdapter.clear(); // I get error here, that is FirstFragment.java:551
...
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);

listItems = new ArrayList();
mAdapter = new MyAdapter(getActivity(), listItems);
listView.setAdapter(mAdapter);
}

}


That is all occuerences of mAdapter. And I can't understand, how it can cause NullPointerException. I think that sometimes Fragment1 destroying and recreating, but without onCreateView(). I talk with one of users which have this problem and he say me, that this bug run away after he uncheck "Don't keep activities" in "Developer options" in settings. I don't know, can I fix it? Or I need to say all my users "uncheck this option"?


In my NainActivity:



public class MainActivity extends FragmentActivity {

Vector fragments;
ViewPager viewPager;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

viewPager = (ViewPager) findViewById(R.id.pager);

fragments = new Vector();
fragments.add(Fragment.instantiate(this, Fragment1.class.getName()));
fragments.add(Fragment.instantiate(this, Fragment2.class.getName()));

viewPager.setOffscreenPageLimit(fragments.size());
PagerAdapter pagerAdapter = new PagerAdapter(super.getSupportFragmentManager(), fragments);

viewPager.setAdapter(pagerAdapter);

viewPager.setCurrentItem(0);
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode==1) {
((MainChat)fragments.get(0)).load();
}
}

class PagerAdapter extends FragmentPagerAdapter implements IconPagerAdapter {

private List fragments;

public PagerAdapter(FragmentManager fm, List fragments) {
super(fm);
this.fragments = fragments;
}

@Override
public Fragment getItem(int position) {
return this.fragments.get(position);
}

@Override
public int getCount() {
return this.fragments.size();
}

}

}


.

stackoverflow.comm

[android help] Awake phone from sleep with chronometer timer


I am making an interval timer for a stopwatch APP, and I'm using chronometer to display notifications (Run, walk, stop) and play sound. But when the phone is in sleepmode it doesn't do anything.


Is there a way to wake up the phone, to show these notifications (and play the sound), or must I use AlarmManager?


I know how to make the phone stay awake with wakelock and FLAG_KEEP_SCREEN_ON, but I don't know how to awake it from sleep.



.

stackoverflow.comm

[General] Grandfathered unlimited data get iPhone 5


So I am on a family plan (not share everything) with one other person who has limited data 2gb plan with iPhone 4S. I have an unlimited data plan with a droid 2 on verizon network. I would like to switch to the iPhone without losing unlimited or paying rediculous retail of 650. I have an upgrade currently available and another one available in two months. I am wondering several things;
Can the other person(with limited data and iPhone 4S) use my upgrade to go to the iPhone 5 and I take their iPhone 4S and keep unlimited data?
Can the other person (limited data and iPhone 4S) use my upgrade to go to the iPhone 5, activate it the deactivate it and switch back to the iPhone 4S and give me the iPhone 5 on my unlimited data plan?

Ay help in this area would be greatly appreciated as I have heard many things!!



.

forum.xda-developers.com

[General] running espier launcher need help with androide widgets


I'm not familiar with that launcher, but for two I have used, you long press the screen and a menu pops up. In Go Launcher, you had to do it from their menu dock that came up when you swiped up from the bottom. See if any of those help while waiting for someone with experience with this launcher to answer. You can also email the developer usually to ask.

Good luck.

Sent from my totally awesome Sprint Galaxy Nexus, even if I don't know all its secrets yet.



.

forum.xda-developers.com

[General] A folder widget?


That varies with what file explorer you use. Some have a widget that allows instant access to a folder of your choice, Others don't have such capability.



.

forum.xda-developers.com

[android help] Notification Not showing


Case study: I need a program that will add a notification at android. And when someone click on the notification it should lead them to my second activity.


I have established a code. It should be working. Dont know what am i missing.


My code structure.


java files:



MainActivity.java
NotificationReceiverActivity.java


Layout file:



activity_main.xml
result.xml


Code of those files:


MainActivity.java



public class MainActivity extends Activity {



@Override
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

}
public void createNotification(View view) {
// Prepare intent which is triggered if the
// notification is selected
Intent intent = new Intent(this, NotificationReceiverActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);

String longText = "Hello Hello Hello";

Notification n = new Notification.Builder(this)
.setContentTitle("New mail from " + "test@gmail.com")
.setContentText("Subject")
.setContentIntent(pIntent).setAutoCancel(true)
.setStyle(new Notification.BigTextStyle().bigText(longText))
.build();

NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Hide the notification after its selected

notificationManager.notify(0, n);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}


NotificationReceiverActivity.java



public class NotificationReceiverActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.result);
}
}


activity_main.xml




android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">




result.xml




android:layout_width="match_parent" android:layout_height="match_parent">
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/textView1">




AndroidManifest.xml



package="com.example.notification"
android:versionCode="1"
android:versionName="1.0" >

android:minSdkVersion="16"
android:targetSdkVersion="15" />

android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:name=".MainActivity"
android:label="@string/title_activity_main" >














.

stackoverflow.comm

[android help] ClassCastException TextSwitcher to Adview

java - ClassCastException TextSwitcher to Adview - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















My xml layout is:



xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#C5C6E1"
android:orientation="vertical"
tools:context=".MainActivity" >

android:id="@+id/topll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId=""
ads:loadAdOnCreate="true" >


android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Drag to set font size" />

android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:progress="25" />


android:id="@+id/ll"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >

android:id="@+id/titleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/questionTEXT"
android:textStyle="bold" />

android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/titlefav"
android:layout_below="@+id/titleText"
android:lines="15" >


android:id="@+id/titlefav"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/adView1"
android:layout_alignParentLeft="true" >

android:id="@+id/tipText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Swipe for more quotes"
android:textSize="14sp"
android:textStyle="bold" />

android:id="@+id/fav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="@drawable/f_disable" />


android:id="@+id/adView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="SMART_BANNER"
ads:adUnitId=""
ads:loadAdOnCreate="true" >






When I try to get the textswitcher as: tv = (TextSwitcher) findViewById(R.id.textView1);


I get the following exception:


android.widget.TextSwitcher cannot be cast to com.google.ads.AdView. Any ideas why this is happening?
















Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.










lang-java






.

stackoverflow.comm

[android help] gridView vertical separator not visible in android


I generated a custom grid view, by passing to my adapter an ArrayList with Arrays of Strings.


Everything is working fine, my gridView is generated as I want (every String Array represents a column in my gridView).


The only problem is, that I can not see vertical separators in the gridview, only the horizontal ones are visible. I really need the vertical separators as well. Please help me with this.


Here is my xml




android:id="@+id/gridview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:columnWidth="130dp"
android:horizontalSpacing="10dp"
android:verticalSpacing="10dp"
android:gravity="center"
android:stretchMode="columnWidth"/>


Here is my code



ArrayList list = new ArrayList();
String [] id = {"IDs", "S001","S002","S003","S004","S005","S006","S007"};
String [] name = {"NAMES", "Rohit","Rahul","Ravi","Amit","Arun","Anil","Kashif"};
String [] products = {"Products", "Bear","Tea","Apple","Food","Color","Program","Telephone"};
String [] stuff = {"Stuffs", "Stuff_01","Stuff_02","Stuff_03","Stuff_04","Stuff_05","Stuff_06","Stuff_07"};
list.add(id);
list.add(name);
list.add(products);
list.add(stuff);

gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new DataAdapter(this, list));


My Custom Adapter



public class DataAdapter extends BaseAdapter {

Context mContext;
private ArrayList list;
private LayoutInflater mInflater;
private ArrayList layouts = new ArrayList();

public DataAdapter(Context c, ArrayList myList)
{
mContext=c;
mInflater = LayoutInflater.from(c);

list = myList;
}

@Override
public int getCount()
{
return list.get(0).length;
}

@Override
public Object getItem(int position)
{
return layouts.get(position);
}

@Override
public long getItemId(int position)
{
return position;
}


@Override
public View getView(int position, View convertView, ViewGroup parent)
{
LinearLayout view;

if (convertView == null) {
view = new LinearLayout(mContext);

for (int i = 0; i < list.size(); i++) {

TextView tv = new TextView(mContext);
tv.setLayoutParams(new GridView.LayoutParams(80, 30));

view.addView(tv);
}

layouts.add(position, view);
}
else {
view = (LinearLayout) convertView;
}

for (int i = 0; i < view.getChildCount(); i++) {
TextView tv = (TextView) view.getChildAt(i);
tv.setText(list.get(i)[position]);
}

view.setBackgroundColor(Color.BLUE);

return view;
}


}



.

stackoverflow.comm

[android help] Live Audio Streaming Between Android Device and a Laptop

Live Audio Streaming Between Android Device and a Laptop - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















I want to send an LIVE audio stream to a laptop using an android device via WIFI. The audio stream is inputted to the android device using the MIC of the android device. And the stream should be streamed LIVE. Please be kind enough to share the knowledge. Thanks in advanced.
















Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.










default






.

stackoverflow.comm

[android help] ActionBar Tab and Master Detail Layout


I'm having an issue with the actionbar tabs and getting the master/detail layout to work.


I have the a master/detail working but I am now adding tabs, so I can select a different layout. But, it seems to crash with the error:



04-27 13:00:45.805: E/AndroidRuntime(5161): android.view.InflateException: Binary XML file line #24: Error inflating class fragment
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-27 13:00:45.805: E/AndroidRuntime(5161): at com.example.example.masterdetail_tabs.Tab1Fragment.onCreateView(Tab1Fragment.java:17)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.app.Fragment.performCreateView(Fragment.java:1695)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:885)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.app.FragmentManagerImpl.attachFragment(FragmentManager.java:1255)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.app.BackStackRecord.run(BackStackRecord.java:672)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1435)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.app.FragmentManagerImpl$1.run(FragmentManager.java:441)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.os.Handler.handleCallback(Handler.java:725)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.os.Handler.dispatchMessage(Handler.java:92)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.os.Looper.loop(Looper.java:137)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-27 13:00:45.805: E/AndroidRuntime(5161): at java.lang.reflect.Method.invokeNative(Native Method)
04-27 13:00:45.805: E/AndroidRuntime(5161): at java.lang.reflect.Method.invoke(Method.java:511)
04-27 13:00:45.805: E/AndroidRuntime(5161): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-27 13:00:45.805: E/AndroidRuntime(5161): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-27 13:00:45.805: E/AndroidRuntime(5161): at dalvik.system.NativeStart.main(Native Method)
04-27 13:00:45.805: E/AndroidRuntime(5161): Caused by: java.lang.IllegalArgumentException: Binary XML file line #24: Duplicate id 0x7f060001, tag null, or parent id 0x0 with another fragment for com.example.example.masterdetail_tabs.ItemListFragment
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:285)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)


I have created a simple application to recreate the issue (don't know if it's an issue but I'm using actionbarsherlock in the real app)


https://github.com/abidk/android_masterdetail_tab_issue


Does anyone have any ideas what I am doing wrong?



.

stackoverflow.comm

[android help] Facebook sdk3 publish


After reading the FB publish tutorial


I'm trying to implement a simple publish, but in my application the user doesn't have to be logged in via FB. I want to open the loggin if needed and if so share.


And I got the next exception:



04-28 12:15:57.350: E/AndroidRuntime(32241): FATAL EXCEPTION: main
04-28 12:15:57.350: E/AndroidRuntime(32241): java.lang.UnsupportedOperationException: Session: an attempt was made to request new permissions for a session that has a pending request.
04-28 12:15:57.350: E/AndroidRuntime(32241): at com.facebook.Session.requestNewPermissions(Session.java:968)
04-28 12:15:57.350: E/AndroidRuntime(32241): at com.facebook.Session.requestNewPublishPermissions(Session.java:501)


My code:



@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
boolean isFacebookResponse =
Session.getActiveSession().onActivityResult(getActivity(), requestCode, resultCode, data);
if (isFacebookResponse) {
shareViaFacebook();
}
}

private void CheckFacebookLogin(){
if(Session.getActiveSession() == null){
logInToFacebook();
}else{
shareViaFacebook();
}
}

private void shareViaFacebook() {
Session session = Session.getActiveSession();

if (session != null){

// Check for publish permissions
List permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session
.NewPermissionsRequest(this, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}

Bundle postParams = new Bundle();
postParams.putString("name", "Facebook SDK for Android");
postParams.putString("caption", "Build great social apps and get more installs.");
postParams.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
postParams.putString("link", "https://developers.facebook.com/android");
postParams.putString("picture", "https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");

Request.Callback callback= new Request.Callback() {
public void onCompleted(Response response) {
JSONObject graphResponse = response
.getGraphObject()
.getInnerJSONObject();
String postId = null;
try {
postId = graphResponse.getString("id");
} catch (JSONException e) {
Log.i(GA_CATEGORY,
"JSON error "+ e.getMessage());
}
FacebookRequestError error = response.getError();
if (error != null) {
Toast.makeText(getActivity()
.getApplicationContext(),
error.getErrorMessage(),
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getActivity()
.getApplicationContext(),
postId,
Toast.LENGTH_LONG).show();
}
}
};

Request request = new Request(session, "me/feed", postParams,
HttpMethod.POST, callback);

RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
}
}

private boolean isSubsetOf(Collection subset, Collection superset) {
for (String string : subset) {
if (!superset.contains(string)) {
return false;
}
}
return true;
}

private void logInToFacebook() {
String app_id = getString(R.string.app_id);

Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);

Session session = new Session.Builder(getActivity())
.setApplicationId(app_id)
.build();
session.addCallback(this);
Session.setActiveSession(session);

// Login
if (!session.isOpened() && !session.isClosed()) {
session.openForRead(new Session.OpenRequest(this)
.setCallback(this));
} else {
Session.openActiveSession(getActivity(), true, this);
}
}


The login code works. What I'm doing wrong?



.

stackoverflow.comm

[General] no downloads possible on galaxy grand


I cannot download any app from the play store, neither any file be it pdf, .doc , .ppt or anything. Though my internet speed is pretty fast and I've storage space in plenty plus my firmware is up to date! What could be the possible reason for having this problem?? Please help!



.

forum.xda-developers.com

[General] whatsapp for samsung


basically my whatsapp expired and it says I have to pay for it to get it working normally again. So far I've changed the date to yesterday to avoid paying but my question is:
is this happening to all other android phones or did something go wrong in mine? and it there a way to avoid having to ever pay? (unlikely but still may as well ask)



.

forum.xda-developers.com

[General] Frustrated with backup / root of android phone - Samsung galaxy grand - pls help


Frustrated with backup / root of android phone - Samsung galaxy grand - pls help

Hi Experts,
I have been reading and reading and reading threads and posts from last so many days to make sure I understand before rooting my newly purchased Samsung galaxy grand I9082.

However even after trying my best I am still confused. Pls help me clarify following questions.

Pls see my phone's existing firmware / OS status: Refer link below or attached screenshot

Q 1. I trust my above phone is right now having latest firmware from Samsung? How do i root without downgrading my firmware?
(Many forum posts seems to suggest rooting process but it downgrades firmware i believe)

Q2. After rooting can i continue to use Kies?

Q3. After rooting can i continue to update Samsung future updates?

Q4. What’s best effective backup method before rooting?

Q5. Will it be possible to safely revert back to position right now after rooting?

Pls address my questions in sufficient detail so that I can realize my dream of rooted android phone.

Thank you in advance for your time.

Anxiously looking forward for your helpful replies to move forward pls.



.

forum.xda-developers.com

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...