Wednesday, April 17, 2013

[android help] Android: DialogFragment and universal xml

Android: DialogFragment and universal xml - 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 take control of the database in android with Dialog Fragments. I mean, for example to add a new record I will click a button and pop-up fragment appears asking me for the specific fields. I click ok which fires the method in my hosting activity. That part works.


However, I also want to have other operations like delete, update, search record ect.


Is there a way to have a universal code for fragment but then assign different xml according to different database operations? I am looking for the most efficient way around my problem.


Thanks!


























You can inflate different views on your Fragment...



public class MyClass extends Fragment {
String xmlToLoad;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstances);
Bundle data = getArguments();
xmlToLoad = data.getString("what you set in your fragments pager");
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if(xmlToLoad.equals("whatever")) {
View view = inflater.inflate(R.layout.thisXML, container,false);
}
}
}



















default






.

stackoverflow.comm

[android help] my soundpool project won't play properly?


I've been trying to implement this soundpool class (with some help from a tutorial) but when I try to run it on a virtual device, the sound won't play... The main_activity XML file loads fine, but it was expected that on loading, a sound would be played.


here is the source code.



public class MainActivity extends Activity {

private SoundPool soundpool;
private boolean soundPoolLoaded = false;

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

// Create a new SoundPool instance.
// 2 = number of sounds that can be simultaneously played
// AudioManager.STREAM_MUSIC = The type of sound stream. STREAM_MUSIC is the most common one
// 0 = sound quality, default is 0.
// setOnLoadCompleteListener loads the file
soundpool = new SoundPool(2, AudioManager.STREAM_MUSIC, 0);
soundpool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
@Override
public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
soundPoolLoaded = true;
}
});

playSound("car_phonic");
}


// This method will load a sound resource from the res/raw folder by the input name given as a string (soundName).
// If the sound resource is found by name, it will attempt to play the sound
// soundPoolLoaded value becomes true when the file is fully loaded
public void playSound(String soundName) {
if(soundPoolLoaded == true)
{
// Get the current context resources and find the correct sound resource for playing the sound
Resources res = this.getResources();
int soundId = 0;
soundId = res.getIdentifier(soundName, "raw", this.getPackageName());

if(soundId != 0){
soundpool.play(soundId, 1, 1, 0, 0, 1);
}


SystemClock.sleep(500);
playSound(soundName);

}
}
}


Any help would be appreciated! Thanks



.

stackoverflow.comm

[General] Applications Crashing....MAX RAM?!


The way Android works, it will always want to fill up free RAM with processes so that they're more quickly accessible when you need them. In general, RAM will optimally be used at around 70-80%. I'm not a total Android techie, so I can't give you the down and dirty details, but in short, when the system detects that it's crossed a certain threshold of RAM usage, it will start shutting down less recently used processes to free up more RAM. 400 MB out of 812 MB RAM used is pretty low, and would not be how things are supposed to work. However, 790 MB out of 812 MB RAM used is pretty high, so that could explain why your phone's been acting a little loopy.

If things keep bogging down even after a restart, I would suspect one of your apps misbehaving. When your memory usage is up around 790 MB, take a screenshot of your Running Apps screen under Settings/Apps/Running, so we can see which one the hog is.



.

forum.xda-developers.com

[General] SD card memory caps


Hi All:
just gone into the android world by purchasing a cheap android tablet, dint want to commit 2 years to do any of the carrier for now until later, its Ice Cream sandwich by the way

one question i run into is the SD card, the tablet came with 4GB of memory internally, i purchased a 32GB SD card hoping to boost its usability, and used a few apps to "move app to SD" its been working good, but its not showing any size decreased in the SD card after i moved about 30-40 apps to the SD card using these app, its still saying it has 29GB or so and used none of it , this is the reading from the built-in "disk usage" meter in the device management options...., and i downloaded a few more app that gives me the reading of the SD card status and usage, it gave me much less than what i expected, it said my SD card only has 1.7GB total give or takes

so this kind of puzzles me, how can we tell if which usage data is right ? is my cheap tablet being cheap because of this so it would only see about 2GB of the 32GB SD card maybe this was the reason ??

thanks for your help and advise



.

forum.xda-developers.com

[android help] Action bar overflow menu vs hardware permanent menu button


I'd tested my app on a Nexus 10 (Android 4.2.1), and the overflow menu on the action bar worked fine. So I was dumbfounded when the overflow menu didn't appear on a Galaxy note 2. After reading Android action bar not showing overflow and How To Control use of OverFlow Menu in ICS, I eventually realised that on the Galaxy note 2 there's a built in menu button, and the "overflow menu" comes up if one presses that button.


The responses to those two questions suggest that one should not use the code there to disable to permanent menu button, because although it has the effect of (a) making the overflow menu appear in the action bar, apparently it also (b) forces the same behavior in other apps too. However, for me the overflow menu in the action bar is far superior to the menu button, and comments left on those two questions suggest that some other people think so too.


My question is, what is it possible to use that code to disable the permanent menu button in onResume(), and re-enable it in onPause()? How reliable a method would that be to make the action bar overflow menu work in my chosen app, with all other apps left unchanged?


Just for the record, it seems to me that the Android designers (both software and hardware) have somehow conspired to create this problem, and there's no easy solution. Some programmers think that having all apps work in the same way on a single device is more important than having any particular app work the same way across different devices. Other programmers think the opposite.



.

stackoverflow.comm

[android help] Android Webview - Programmatically change orientation for specific webpage without reloading


I'm trying to see how to go about changing a webview on a certain page so if that page contains a video they can watch it in landscape mode. I would like it to not reload the webview but allow that page to rotate. How can that be done? Not sure how to even go about it.



.

stackoverflow.comm

[General] Micro SD card died. Airdroid transfer gone awry?


One of two things happened:

Your SD card is old, and they can go bad. It could just be a coincidence as far as timing is concerned.

Your phone somehow lost it's connection with the SD card momentarily while data was being read or written. Could be a software issue, a hardware issue, but honestly, whatever the cause, I imagine it's just a fluke.

I wouldn't worry about it happening again.

If you want, try to put it in an SD card reader on your PC and see if the computer will read it. If you've kissed all your data goodbye already, try to format it while it's in the phone (using the options under Settings > Storage) and see if it fires back up.



.

forum.xda-developers.com

[android help] Android Action Bar Drawers


I'm searching for some information about the Acion Bar Drawers described here: http://developer.android.com/design/patterns/actionbar.html ("Drawers: A drawer is a slide-out menu that allows users to...")


Seems like this feature is part of Android and no external library, but I can't find any information about how to implement this feature.



.

stackoverflow.comm

[android help] Draw with ontouch based on menu selection


I have three menu items: Line, Circle, and Rectangle. I want to set it so that depending on the menu item selected, that shape/line is drawn when the user drags their finger across the screen(aka rubber banding). Here's LineDrawView.java:



// Project: Java2Lab11_Lefelhocz
// File: LineDrawView.java
// Date: 4/10/13
// Author: Joshua Lefelhocz
// Description: custom view to draw lines on

package com.lcc.java2lab12_lefelhocz;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.MotionEvent;
import android.view.View;

// Notice this class extends View
public class LineDrawView extends View
{
// This view's bounds

@SuppressWarnings("unused")
private int xMin = 0;
@SuppressWarnings("unused")
private int xMax;
@SuppressWarnings("unused")
private int yMin = 0;
@SuppressWarnings("unused")
private int yMax;
private float currentX;
private float currentY;
private float startX;
private float endX;
private float startY;
private float endY;
// Paint object
private Paint paintFill;

// constructor
public LineDrawView(Context context)
{
// call the super class constructor
super(context);

// The Paint class holds the style and color information about how to draw geometries, text and bitmaps.
// For efficiency create the paint objects in the constructor, not in draw
// paint.setStrokeWidth(10); // works on lines
// You can change the color of Paint without effecting objects already drawn
// You can NOT change the style of Paint without effecting objects already drawn
// The Style, TextSize apply to all objects drawn with the paint.

// Create a default Paint object Style=Fill
paintFill = new Paint();

// set the background color when the view is created
this.setBackgroundColor(Color.LTGRAY);
}

// Called to draw the view. Also called by invalidate().
@Override
protected void onDraw(Canvas canvas)
{



paintFill.setColor(Color.BLACK);
canvas.drawLine(startX, startY, endX, endY, paintFill);

}

// Called when the view is first created or its size changes.
@Override
public void onSizeChanged(int width, int height, int oldWidth, int oldHeight)
{
// Set the view bounds
xMax = width-1;
yMax = height-1;
}

public boolean onTouchEvent(MotionEvent event)
{
currentX = event.getX();
currentY = event.getY();



switch(event.getAction())
{
case MotionEvent.ACTION_DOWN:
startX = currentX;
startY = currentY;
return true;
case MotionEvent.ACTION_MOVE:
endX = currentX;
endY = currentY;
invalidate();
return true;
case MotionEvent.ACTION_UP:


return true;
}
return super.onTouchEvent(event);
}
}


Extra details: I am starting to get it to work, but am having trouble making the distance formula {sqrt(x2-x1)^2 + (y2-y1)^2)}



.

stackoverflow.comm

[android help] Android : How to Create Android Emulator for Nexus10?

Android : How to Create Android Emulator for Nexus10? - 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 create the android emulator for Nexus 10 using latest ADT(21) and SDK tools. Having below configurations for Nexus 10 AVD.



Screen Size - 10 inches
Resolution - 2560 X 1600
Screen Size - xlarge Screen Density - Xhdpi
Screen ratio - long
RAM - 1024


Let me know if i'm wrong in configuration. after giving above Configuration i able to create AVD but couldn't load it. it continuously showing black screen. what Could be the Problem Here? bdw I am Using Ubantu 11.10


Thnks in Advance.





























I had the same issue. You can do one thing,


1) When you create AVD, make sure Use Host GPU option is checked.


enter image description here


It worked for me, in my Mac OS X Mountain Lion 10.8.2, and eclipse juno.


EDIT : Sorry folks for the confusion. There is no Google Nexus 10 skin (at the time of writing this). What you see in the image is a Nexus 10 equalant I created using Device Definition (AVD manager 2nd tab) feature of eclipse. It is just I named it as Nexus 10 and it is not default google emulator.


























I had the same issue (have, actually). It is quite simple, the resolution and the screen density are just too high for your monitor (on that screen size), so it cannot display it. - I am sure your emulator runs perfectly on other configurations






















With IntelliJ you need to open tools - android - AVD manager and then when you add a new AVD try ensuring that your CPU/ABI is set to ARM(armeabi) Had some trouble before like this and it was down to this setting.


Hope this helps!






















This is the correct configuration for an Nexus 10 Android Virtual Device:


Nexus10_AVD


Your screensize and density was wrong.



Screen Size - 10.1 inches
Resolution - 2560x1600
Size - xlarge
Density - xxhdpi
Screen Ratio - long
RAM - 2048 MiB





















default






.

stackoverflow.comm

[android help] Trying to set color to my text in android


I am trying to set color for my text in android. Every time i launch my application it shuts down. Here is what i have in color.xml file:





#006400
#FFE4C4


here is what i have in my MainActivity Class:



int textColor = getResources().getColor(R.color.app_text_color);

TextView helloText = (TextView)findViewById(R.string.hello_world);

helloText.setTextColor(textColor);


Here is the layout file:



xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_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=".MainActivity" >

android:id="@+id/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
/>




Log Car:



04-17 21:00:39.290: E/AndroidRuntime(9986): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1670)


.

stackoverflow.comm

[android help] ArrayIndexOutOfBoundsException on collision detection


I have a sprite and I have a maze which is randomly generated so I have a method here which checks if a wall is there and return true if there is.


I have a maze which is drawn and checks if there is a wall:



public boolean isWall(int oldX, int oldY, int newX, int newY) {
boolean wallPresent;
if ((oldX == newX) && (oldY == newY)) { wallPresent = false; }
else if (newX == oldX - 1) {
wallPresent = west[oldX][oldY];
} else if (newX == oldX + 1) {
wallPresent = east[oldX][oldY];
} else if (newY == oldY - 1) {
wallPresent = north[oldX][oldY];
} else if (newY == oldY + 1) {
wallPresent = south[oldX][oldY];
} else { wallPresent = false; }

if ((oldX != newX) && (oldY != newY)) {
if ((newX == oldX + 1) && (newY == oldY + 1) &&
(north[newX][newY] || west[newX][newY]) ) {
wallPresent = true;
} else if ((newX == oldX + 1) && (newY == oldY - 1) &&
(south[newX][newY] || west[newX][newY]) ) {
wallPresent = true;
} else if ((newX == oldX - 1) && (newY == oldY + 1) &&
(north[newX][newY] || east[newX][newY]) ) {
wallPresent = true;
} else if ((newX == oldX - 1) && (newY == oldY - 1) &&
(south[newX][newY] || east[newX][newY]) ) {
wallPresent = true;
}
}

return wallPresent;
}


I have also created a sprite in the form of a bitmap image and this is my movement and collision detection:


public void onDraw(Canvas canvas) {



while (Game.pressedUp) {
movementGo();
}

// update();
// SOURCE EDU4JAVA - www.edu4java.com
// using the rows and columns of the sprite field, separate the required
// sprite
int srcX = currentFrame * width;
int srcY = direction * height;

src = new Rect(srcX, srcY, srcX + width, srcY + height);
dst = new Rect(x, y, x + width, y + height);
//System.out.println(x);
//System.out.println(y);
// SOURCE END
canvas.drawBitmap(bmp, src, dst, null);
}
//x+width
private boolean canBallMove(int x, int y) {
int cellWidth = 64;
int newMidX = x + x/2;
int newMidY = y + y/2;

// Find out which cell ball's middle was in.
// Note that this division will round down, which is correct
int oldCellX = x + xSpeed/cellWidth +1;
int oldCellY = y + xSpeed/cellWidth +1;

// Find out which cell ball's middle would be in now
int newCellX = newMidX/cellWidth + 1 ;
int newCellY = newMidY/cellWidth + 1;
System.out.println(newCellX);
System.out.println(newCellY);
if ((newMidX % cellWidth) + x >= cellWidth) {
newCellX++;
}
if ((newMidX % cellWidth) - x <= 0) {
newCellX--;
}
if ((newMidY % cellWidth) + y>= cellWidth) {
newCellY++;
}
if ((newMidY % cellWidth) - y <= 0) {
newCellY--;
}


return !(Game.gameV.isWall(oldCellX, oldCellY, newCellX, newCellY));
}


}


Now, the else statement triggers, meaning that it knows there is a wall nearby but I still think its broken and now I keep getting these ArrayIndexOutOfBoundsException crashes? Any clue anyone?



.

stackoverflow.comm

[android help] Change the Facebook SDK 3.0 Loggin Button Image


Do I understand rightly that you'ved added Facebook's own custom FacebookLoginButton view?


If that's the case, then the constructor FacebookLoginButton(final Context context, final AttributeSet attrs) will be called by the layout inflator, which references the R file of the facebook library- no good.


So if you want to customize that button beyond what is exposed in the facebook sdk, I've had success with copying the view class - FacebookLoginButton.java - into my own project (you may need to tinker with FacebookLoginButton.java to make sure everything references back to the facebook library correctly). Along with it, copy all of the resources referenced by that constructor into your own project. It goes without saying, you'll now need to make sure everything in the copied class references your projects resources now.


Finally, you'll of course need to change the button class in your layout file to the fully qualified class name to that copied FacebookLoginButton in your own project.


Hope this helps.



.

stackoverflow.comm

[android help] Android - Using Custom Font

Android - Using Custom Font - 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 applied a custom font to a TextView, but it doesn't seems to change the typeface.


Here is my code:



Typeface myTypeface = Typeface.createFromAsset(getAssets(), "fonts/myFont.ttf");
TextView myTextView = (TextView)findViewById(R.id.myTextView);
myTextView.setTypeface(myTypeface);


Can anyone please get me out of this issue?





























benvd is right. Don't use a fonts subdirectory.


On Mobiletuts+ there is very good tutorial on Text formatting for Android. Quick Tip: Customize Android Fonts


EDIT: Tested it myself now. Here is the solution. You can use a subfolder called fonts but it must go in the assets folder not the res folder. So



assets/fonts



Also make sure that the font ending I mean the ending of the font file itself is all lower case. In other words it should not be myFont.TTF but myFont.ttf


























I've successfully used this before. The only difference between our implementations is that I wasn't using a subfolder in assets. Not sure if that will change anything, though.






















when i have been wrote this code to set my font it dosn't work when i'm start my application suddenly my application is stop..




















default






.

stackoverflow.comm

[android help] How to get rid of double decimal place


I'm trying to get rid of some of the decimal places in a double,I'v done it successfully on other part's of the app but i cant figure it out here. The double is coming in in a extra and i'm setting it to an edit text



double dryFree = sender.getExtras().getDouble("ResultFree");
else if (getIntent().hasExtra("ResultFree")) {
answer.setText( dryFree + "");


This is what i'v tried but app crashes



else if (getIntent().hasExtra("ResultFree")) {
answer.setText(String.format("%.2f", dryFree + ""));


Activity where number is coming from, I tried using string.format here to but getting errors, I know i'm using it wrong



total = (int) (a * b * c) / 0.424753;


.

stackoverflow.comm

[General] update


I have Straight talks Lg Optimus Showtime and i downed LG's mobile updater. however.. when i try and update it says it's able to that my device is not supported. is there a way around this or should i root?



.

forum.xda-developers.com

[General] Screen protectors?


I need help in picking out a screen protector. I usually never use one, so it been a long time since I've purchased any. I'm getting a new phone and would like to get a decent one.

I remember using one before that was somewhat textured looking, left no finger prints or smudges when using the screen. Your finger would smoothly glide across the screen....any suggestions?
Thanks in advance

HTC One X



.

forum.xda-developers.com

[android help] Using APP_STL and Application.mk files in AOSP's external/


I have written several C++ librairies/programs to be used on an Android system. These libraries compile well and are fully tested on x86 using gcc-4.4/gcc4.6. I would like to compile these libraries for ARM without using the NDK's toolchain.


Instead, I would like to place this libraries in the external/ folder of my Android 4.0.4 project where all the external C/C++ libraries needed by Android are actually living. The advantage of this is that the librairies/executables I will compile will be automatically copied in the good path at compile time. Plus, this will allow me to build the whole firmware once including all the dependencies. Finally, this also has the advantage that statical assertions may cause the whole build to fail if anything goes wrong.


I have no trouble doing this for C programs, the problems arise when trying to compile C++ programs that depends on GNU STL. I am aware that Android do not use GNU STL by default and would like to know how I can link my libraries/executables against it as I have already tried the classical Android.mk and Application.mk methods.


The APP_STL variable in my Application.mk seems to be ignored when making my library. I am sourcing and lunching before making.


Here's what my Makefiles look like :


Android.mk



LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := libuinput++

LOCAL_C_INCLUDES := $(LOCAL_PATH)/src/include

LOCAL_CFLAGS := -W -Os -fPIC

LOCAL_SRC_FILES := src/Device.cpp \
src/DeviceConnection.cpp \
src/ConnectionManager.cpp \
src/OutputStream.cpp \
src/Command.cpp

LOCAL_CPP_FEATURES += exceptions

include $(BUILD_STATIC_LIBRARY)


Application.mk



APP_PROJECT_PATH := $(shell pwd)
APP_BUILD_SCRIPT := $(APP_PROJECT_PATH)/Android.mk
APP_STL := gnustl_static


The errors I get :



src/include/Device.hpp:4:18: error: string: No such file or directory
src/include/Device.hpp:5:20: error: stdint.h: No such file or directory


Any tips ?



.

stackoverflow.comm

[android help] Google Maps Android API v2 : Is there a quick way to know if there is a Marker at a given location?


The title says it all : I want to know if there is a Marker at a given LatLng location. Is there any quick way to do this, or do I need to write my own function ?


Thanks in advance.



.

stackoverflow.comm

[General] Phone won't turn on but orange light blinking


My phone has been been on the charger but it won't charge , theres an orange blinking light though the pulsates , no matter how long I leave my phone on the charge it won't turn on what do I do?



.

forum.xda-developers.com

[android help] SOAP response not in XML format


I am developing an application which consume SOAP web service.


When i am getting the response in text view or in log-cat it is in following format as :



anyType{Results=anyType{Row=anyType{NAME=Demo; EMAIL=m.m@gmail.com; PHONENO=98607xxxxx; }; }; }


But on browser the response is like :



xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns0="http://testing.oi.com/">





Demo
m.m@gmail.com
98607xxxxx








My code of calling SOAP web service is as follows :



String NAMESPACE = "http://testing.oi.com/";
String URL = "http://192.168.1.xxx:8888/Testing-DemoTest-context-root/TestDemoSoapHttpPort";
String SOAP_ACTION = "http://testing.xx.com/getDetails";
String METHOD_NAME = "getDetails";

//Initialize soap request + add parameters
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

//Declare the version of the SOAP request
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
envelope.implicitTypes = false;

HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

try {
androidHttpTransport.debug = true;
//this is the actual part that will call the
androidHttpTransport.call(SOAP_ACTION, envelope);
// Get the SoapResult from the envelope body.
SoapObject result = (SoapObject)envelope.bodyIn;
//Xml.parse(result.toString(), dataHandler);
hotelDetails = result.getProperty(0).toString();
Log.d("Rsp",Details);
} catch (Exception e) {
e.printStackTrace();
}

tv.setText(hotelDetails);


My Java web service code is as follows :



public class Test {
public Test() {
}
// Global Variable
Connection con;
CallableStatement cst;
String response;
ResultSet rs;
Statement stmt;

//DataBase Connection
public static Connection getConnection(){
Connection con;
con = null;

try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (ClassNotFoundException e) {
System.out.println("Server Connection Failed");
}

String url="jdbc:oracle:thin:@abc.def.com:PortNo:SID";
try {
con=DriverManager.getConnection(url,"UserName","Password");
if(con!=null){
System.out.println("Connection Success"+"\n");
}
} catch (SQLException e) {

System.out.println("Connection Failed");
}
return(con);
}

//XML Document Creation.
public static Document createXMLDocument(ResultSet resultset, Document doc){
ResultSetMetaData rsmd;
DocumentBuilderFactory factory;
DocumentBuilder builder;
doc = null;
Element results;
int colCount;
Connection con = getConnection();

try{
factory = DocumentBuilderFactory.newInstance();
builder= factory.newDocumentBuilder();
doc= builder.newDocument();
results = doc.createElement("Results");
doc.appendChild(results);
rsmd = resultset.getMetaData();
colCount = rsmd.getColumnCount();

while (resultset.next()){
Element row = doc.createElement("Row");
results.appendChild(row);

for (int i = 1; i <= colCount; i++){
String columnName = rsmd.getColumnName(i);
Object value = resultset.getObject(i);
if(value==null){
value=" ";
}

Element node = doc.createElement(columnName);
if(columnName.equalsIgnoreCase("BEGIN_DATE")){
String date= resultset.getString(i);
node.appendChild(doc.createTextNode(date));
row.appendChild(node);
}else{
node.appendChild(doc.createTextNode(value.toString()));
row.appendChild(node);
}
}
}
}catch (Exception e) {
e.printStackTrace();
}
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
return(doc);
}

// Call Details
@WebMethod
public Document getDetails(){
Document doc;
doc = null;
con=getConnection();
try {
cst= con.prepareCall("{call callDetails (?)}");
cst.registerOutParameter(1,OracleTypes.CURSOR);
cst.execute();
rs = (ResultSet)cst.getObject(1);
doc = createXMLDocument(rs,doc);
}catch (SQLException e) {
System.out.println("No Such Record");
}

try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
return(doc);
}


I want the response as like it is on browser in string so that i can use sax parsing and parse data. I am not getting what is the issue that why i am getting such response.


Please guide me in this issue or suggest me what should i do now. I am in the middle of app and can not able to move farther.



.

stackoverflow.comm

[android help] android web view not getting displayed as part of screen


my activity code



public class MainActivity extends Activity {
Spinner spinnerProduct;
WebView webView1, webView2, webView3;
private Handler mHandler = new Handler();

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

spinnerProduct = (Spinner) findViewById(R.id.spinner_select_product);

List list = new ArrayList();
list.add("Product 1");
list.add("Product 2");
list.add("Product 3");

ArrayAdapter dataAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, list);
spinnerProduct.setAdapter(dataAdapter);

dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

spinnerProduct.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView arg0, View arg1, int arg2, long arg3) {
Toast.makeText(getApplicationContext(), "Product " + ++arg2 + " selected", Toast.LENGTH_LONG).show();
showHtml();
}

@Override
public void onNothingSelected(AdapterView arg0) {
}
});
}

public void showHtml() {
Log.v("in showHtml", "in showHtml");
webView1 = (WebView) findViewById(R.id.web_view1);
WebSettings webSettings = webView1.getSettings();
webSettings.setJavaScriptEnabled(true);

webSettings.setSavePassword(true);
webSettings.setSaveFormData(true);
webSettings.setSupportZoom(true);

// webView1.addJavascriptInterface(new DemoJavaScriptInterface(),
// "demo");

webView1.loadUrl("file:///android_asset/product.html");

webView1.setWebChromeClient(new MyJavaScriptChromeClient(getApplicationContext()));
}}


My xml code



xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:weightSum="10"
tools:context=".MainActivity" >

android:id="@+id/ll_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >

android:id="@+id/tv_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/app_name" />


android:id="@+id/ll_select_product"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center"
android:orientation="vertical" >

android:id="@+id/spinner_select_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />


android:id="@+id/ll_web_views"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="7"
android:orientation="horizontal"
android:weightSum="3" >

android:id="@+id/web_view1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1" />

android:id="@+id/web_view2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1" />

android:id="@+id/web_view3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1" />



I checked logcat, showHtml() method gets called(it prints "in html").


But web view doesn't get displayed.



.

stackoverflow.comm

[android help] SecurityException: Permission Denial. opening provider xxx from xxx that is not exported from uid 10027

android - SecurityException: Permission Denial. opening provider xxx from xxx that is not exported from uid 10027 - 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 have a project A as library jar file, which contains a ContentProvider. Then I need to use it in project B. As declared in Manifest:



android:authorities="com.gezbox.android.onepiece"
android:exported="true"
android:name="com.gezbox.android.api.provider.GezboxProvider"/>


But problem comes then:



04-17 17:55:50.695: WARN/dalvikvm(5527): threadid=13: thread exiting with uncaught exception (group=0x40def300)
04-17 17:55:50.695: WARN/ActivityManager(258): Permission denied: checkComponentPermission() owningUid=10027
04-17 17:55:50.695: WARN/ActivityManager(258): Permission denied: checkComponentPermission() owningUid=10027
04-17 17:55:50.695: WARN/ActivityManager(258): Permission Denial: opening provider com.gezbox.android.api.provider.GezboxProvider from ProcessRecord{415d5e08 5527:com.gezbox.android.onepiece/u0a31} (pid=5527, uid=10031) that is not exported from uid 10027
04-17 17:55:50.711: ERROR/AndroidRuntime(5527): FATAL EXCEPTION: IntentService[GezboxService]
java.lang.SecurityException: Permission Denial: opening provider com.gezbox.android.api.provider.GezboxProvider from ProcessRecord{415d5e08 5527:com.gezbox.android.onepiece/u0a31} (pid=5527, uid=10031) that is not exported from uid 10027

at android.os.Parcel.readException(Parcel.java:1425)
at android.os.Parcel.readException(Parcel.java:1379)
at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:2354)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:4219)
at android.app.ContextImpl$ApplicationContentResolver.acquireProvider(ContextImpl.java:1688)
at android.content.ContentResolver.acquireProvider(ContentResolver.java:1083)
at android.content.ContentResolver.acquireContentProviderClient(ContentResolver.java:1146)
at android.content.ContentResolver.applyBatch(ContentResolver.java:896)
at com.gezbox.android.api.processor.PostOrderProcessor.updateContentProvider(PostOrderProcessor.java:57)
at com.gezbox.android.api.processor.PostOrderProcessor.post_order(PostOrderProcessor.java:33)
at com.gezbox.android.api.GezboxService.onHandleIntent(GezboxService.java:196)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.os.HandlerThread.run(HandlerThread.java:60)


















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










default






.

stackoverflow.comm

[android help] Setting ActionBarSherlock Theme for Android app


READ UPDATE 2 BELOW FOR THE ANSWER


I'm trying to use ActionBarSherlock in my app. I checked out the 4.0.0 release from the project github repo, built it in Netbeans, then copied the library-4.0.0.jar file into my project's lib directory (I'm not using Eclipse).


It's just a skeleton activity right now, and it launches just fine in ICS, but when I run it on Gingerbread I get the following exception complaining that I haven't the app theme to Theme.Sherlock (or similar):



java.lang.RuntimeException: Unable to start activity ComponentInfo{com.arashpayan.prayerbook/com.arashpayan.prayerbook.PrayerBook}: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
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:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
at com.actionbarsherlock.internal.ActionBarSherlockCompat.generateLayout(ActionBarSherlockCompat.java:987)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.installDecor(ActionBarSherlockCompat.java:899)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:852)
at com.actionbarsherlock.ActionBarSherlock.setContentView(ActionBarSherlock.java:655)
at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:316)
at com.arashpayan.prayerbook.PrayerBook.onCreate(PrayerBook.java:44)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
... 11 more


The line it complains about (PrayerBook:44) is the call to setContentView. The app just consists of a single activity with an onCreate() method that I call setTheme() from at the top:



public void onCreate(Bundle savedInstanceState)
{
setTheme(com.actionbarsherlock.R.style.Theme_Sherlock);
super.onCreate(savedInstanceState);

TextView rootTextView = new TextView(this);
rootTextView.setText("Hello, world!");
setContentView(rootTextView);

getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ActionBar.Tab tab = getSupportActionBar().newTab();
tab.setText("Prayers");
getSupportActionBar().addTab(tab);

tab = getSupportActionBar().newTab();
tab.setText("Recents");
getSupportActionBar().addTab(tab);

tab = getSupportActionBar().newTab();
tab.setText("Bookmarks");
getSupportActionBar().addTab(tab);
}


I must be setting the theme incorrectly, but I just don't see how. Can anyone help?


UPDATE Below, CommonsWare noted that the theme can be set in the AndroidManifest.xml. I've tried that like so:




android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden|screenLayout|uiMode|mcc|mnc|locale|navigation|fontScale|screenSize">





android:name="LanguagesActivity" />



but Ant gives me an error when it tries to build the app:



/Users/arash/coding/prayerbook/AndroidManifest.xml:7: error: Error: No resource found that matches the given name (at 'theme' with value '@style/Theme.Sherlock').


UPDATE 2 With CommonsWare's help in his follow up comments, I was able to get it working. I needed to add ActionBarSherlock as a project dependency. To do so,


1) I removed library-4.0.0.jar and android-support-4.0.jar from my project's lib directory.


2) Next, navigate into the library folder inside the root of the ActionBarSherlock directory checked out from github. Type android update project so a build.xml and proguard.cfg file will be created for the library.


3) Finally, cd back into the main project directory and add ABS as a library dependency with android update project --path . --library ../ActionBarSherlock/library The path to the --library in the command will vary according to where you checked out the repo. ActionBarSherlock and my app's project directory were sibling directories.



.

stackoverflow.comm

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...