I tried the following code with android 2.3.3 (AVD). When i run this code it waits saying Waiting for HOME ('android.process.acore') to be launched... but keeps on waiting. So i tried running second time .. this time it says
[2011-03-04 12:28:39 - DialANumber] Uploading DialANumber.apk onto device 'emulator-5554'
[2011-03-04 12:28:39 - DialANumber] Installing DialANumber.apk...
[2011-03-04 12:29:14 - DialANumber] HOME is up on device 'emulator-5554'
[2011-03-04 12:29:14 - DialANumber] Uploading DialANumber.apk onto device 'emulator-5554'
[2011-03-04 12:29:14 - DialANumber] Installing DialANumber.apk...
and after some time fails with
[2011-03-04 12:31:37 - DialANumber] Failed to install DialANumber.apk on device 'emulator-5554!
[2011-03-04 12:31:37 - DialANumber] (null)
[2011-03-04 12:31:39 - DialANumber] Launch canceled!
the code follows:
package com.DialANumber;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
public class DialANumber extends Activity {
EditText mEditText_number = null;
LinearLayout mLinearLayout_no_button = null;
Button mButton_dial = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mLinearLayout_no_button = new LinearLayout(this);
mEditText_number = new EditText(this);
mEditText_number.setText("5551222");
mLinearLayout_no_button.addView(mEditText_number);
mButton_dial = new Button(this);
mButton_dial.setText("Dial!");
mLinearLayout_no_button.addView(mButton_dial);
mButton_dial.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
performDial();
}
});
setContentView(mLinearLayout_no_button);
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_CALL) {
performDial();
return true;
}
return false;
}
public void performDial(){
if(mEditText_number!=null){
try {
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + mEditText_number.getText())));
} catch (Exception e) {
e.printStackTrace();
}
}//if
}
}
I am just starting to learn developing android apps. please help me out.. Thanks.
I'd like to create a http-centric client for a restful web service created using CXF. To that end:
Does any one know the (maven)
dependencies for ONLY the CXF clients
(Proxy & HTTP)?
Is there any advantage to using CXF's built-in
clients over say, Apache HttpClient?
How to save txt file content to different arrays?
my txt file content is like this;
12 14 16 18 13 17 14 18 10 23
pic1 pic2 pic3 pic4 pic5 pic6 pic7 pic8 pic9 pic10
left right top left right right top top left right
100 200 300 400 500 600 700 800 900 1000
how can I save each line into different array?
e.g. line 1 will be saved in an array1
line 2 will be saved in an array2
line 3 will be saved in an array3
line 4 will be saved in an array4
Thanks you
i am new at programming and i need some help with that please =/
web service is already written but not by me. so all i have to do is send xml as document object by post method through web service.
my code:
public class send extends application {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://app.local/test/");
try {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.newDocument();
Element rootElement = document.createElement("packet");
rootElement.setAttribute("version", "1.2");
document.appendChild(rootElement);
Element em = document.createElement("imei");
em.appendChild(document.createTextNode("000000000000000"));
rootElement.appendChild(em);
em = document.createElement("username");
em.appendChild(document.createTextNode("5555"));
rootElement.appendChild(em);
HttpResponse response = httpclient.execute(httppost);
} catch (Exception e) {
System.out.println("XML Pasing Excpetion = " + e);
}
}
}
It seems the standard approach for deserializing JAXB XML is to specify the package name when creating the context. Then, JAXB looks up the class based on the root element:
JAXBContext jc = JAXBContext.newInstance("com.foo");
Unmarshaller u = jc.createUnmarshaller();
Object o = u.unmarshal(new StringReader("..."));
I'm looking for a more flexible approach where I don't have to specify the package name and could still deserialize any object. This would be as simple as JAXB storing the package in the XML, but I can't seem to find out how to do this. I can write the code to do it myself but that would be unpleasant. It would like JAXB to do it, if possible. BTW, I am not using schemas, just Annotations and marshal/unmarshal. Any ideas?
I recently ran across several objects implemented to handle events with a hard coded mapping using this pattern:
public void handleEvent(Event event)
{
if(event.getCode() == SOME_STATIC_EVENT)
doSomething(event);
if(event.getCode() == ANOTHER_STATIC_EVENT)
doSomethingElse(event);
}
where doSomething functions are implemented as methods of the same class.
In hopes of striving for looser coupling, how would you suggest abstracting out this pattern? Also, what's the best approach for mapping 0..N functions to a fired event?
I want to use the JPA EntityListener to support spring security ACLs.
On @PostPersist events, I create a permission corresponding to the persisted entity.
I need this operation to participate to the current Transaction.
For this to happen I need to have a reference to the application TransactionManager in the EntityListener.
The problem is, Spring can't manage the EntityListener as it is created automatically when EntityManagerFactory is instantiated.
And in a classic Spring app, the EntityManagerFactory is itself created during the TransactioManager instantiation.
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
So I have no way to inject the TransactionManager with the constructor, as it is not yet instantiated.
Making the EntityManager a @Component create another instance of the EntityManager.
Implementing InitiliazingBean and using afterPropertySet() doesn't work as it's not a Spring managed bean.
Any idea would be helpful as I'm stuck and out of ideas.
in my wicket application I have 3 checkbox in form:
add(new CheckBox("1").setOutputMarkupId(true));
add(new CheckBox("2").setOutputMarkupId(true));
add(new CheckBox("3").setOutputMarkupId(true));
form also contain behavior which unselect checboxes
add(new AjaxEventBehavior("onclick") {
private static final long serialVersionUID = 1L;
@Override
protected void onEvent(AjaxRequestTarget target) {
List<Component> components = new ArrayList<Component>();
if (target.getLastFocusedElementId() != null) {
if (target.getLastFocusedElementId().equals("1")) {
components.add(get("2"));
components.add(get("3"));
} else if (target.getLastFocusedElementId().equals("2")) {
components.add(get("1"));
} else if (target.getLastFocusedElementId().equals("3")) {
components.add(get("1"));
}
for (Component component : components) {
component.setDefaultModelObject(null);
target.add(component);
}
}
}
});
this works good on mozilla browser but in chrome this doesnt work. How I can improve to work this on chrome too ?
UPDATE
problem is in:
target.getLastFocusedElementId()
in mozilla this return what I want but in chrome it always return null but I dont know wh
UPDATE 2
google chrome has bug in focus element:
http://code.google.com/p/chromium/issues/detail?id=1383&can=1&q=window.focus%20type%3aBug&colspec=ID%20Stars%20Pri%20Area%20Type%20Status%20Summary%20Modified%20Owner
so I need to do this in other way
My project has several deployed artifacts as ear files. My understanding is that each of the ears will have it's own classloader. Is it possible to tell weblogic to use the same classloader for each of these deployables.
What factors do i need to consider when making this change?
Is it possible to change the unit for Paint.setTextSize()? As far as I know, it's pixel but I like to set the text size in DIP for multiple screen support.
Thanks
Let's say I have the following command bean for creating a user:
public class CreateUserCommand {
private String userName;
private String email;
private Integer occupationId;
pirvate Integer countryId;
}
occupationId and countryId are drop down selected values on the form. They map to an entity in the database (Occupation, Country).
This command object is going to be fed to a service facade like so:
userServiceFacade.createUser(CreateUserCommand command);
This facade will construct a user entity to be sent to the actual service. So I suppose that in the facade layer I will have to make several dao calls to map all the lookup properties of the User entity.
Based on this what is the best strategy to validate that occupationId and countryId map to real entities? Where is the best place to perform this validation? There is the spring validator but I am not sure this is the best place for this, for one I am wary of this method as validation is tied to the web tier, but also that means I would need to make the dao calls in the validator for validation but I would need to call the dao's in the facade layer again when the command - entity translation occurs.
Is there anything I can do better?
Thanks.
hello i am a student and i am doing my senior project it is about developing an application in j2me for scanning a barcode and extract the number of the barcode in a message to be send.
please i search the net but i cant found something usefull i am new at j2me if someone could help me with sourch code and how to create it i will be very thankfull my email is [email protected]
thanks in advanced
im developing a standalone application and it works fine when starting it from my ide(intellij idea), but after creating an uberjar and start the application from it javax.persistence.spi.PersistenceProvider is thrown saying "No Persistence provider for EntityManager named testPU"
here is my persistence.xml which is placed under meta-inf directory:
<persistence-unit name="testPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>test.model.Configuration</class>
<properties>
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.password" value="root"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/test"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
<property name="hibernate.c3p0.timeout" value="300"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
and here is how im creating the entity manager factory:
emf = Persistence.createEntityManagerFactory("testPU");
im using maven and tried the assembly plug-in with the default configuration fot it, i dont have much experience with assembling jars and i dont know if im missing something, so if u have any ideas ill be glad to hear them
Recalling this post enumerating several problems of using singletons
and having seen several examples of Android applications using singleton pattern, I wonder if it's a good idea to use Singletons instead of single instances shared through global application state (subclassing android.os.Application and obtaining it through context.getApplication()).
What advantages/drawbacks would have both mechanisms?
To be honest, I expect the same answer in this post http://stackoverflow.com/questions/2709071/singleton-pattern-with-web-application-not-a-good-idea but applied to Android. Am I correct? What's different in DalvikVM otherwise?
EDIT: I would like to have opinions on several aspects involved:
Synchronization
Reusability
Testing
Thanks in advance.
Is anyone aware of a publicly available Maven repository that contains the Google App Engine 1.3.1 JAR's? I've been using the maven-gae-plugin repository, but it's not updated yet. It looks like the JAR's on the central Maven repository are even older.
EDIT: It looks like Cletus's answer below has most of the JAR's, but not all of them. For example, the datanucleus-appengine-1.0.5.final.jar isn't available.
public Login authenticate(Login login) {
String query = "SELECT L FROM Login AS L WHERE L.email=? AND L.password=?";
Object[] parameters = { login.getEmail(), login.getPassword() };
List<Login> resultsList = (getHibernateTemplate().find(query,parameters));
if (resultsList.isEmpty()) {
//error dude
}
else if (resultsList.size() > 1) {
//throw expections
}
else {
Login login1 = (Login) resultsList.get(0);
return login1;
}
return null;
}
I have my DB tables password col set as MD5, now how to retrieve it back here.
J2SE Client Server App: Client calls RMI message. Server handles RMI method and returns, but Client never receives it.
Any ideas how this could happen? Our attempted solution is to set client read timeouts and come up with a framework for resending requests or otherwise handling those failures gracefully.
But really, I'd like to know any root causes for how this might happen rather than addressing the symptoms.
My specific problem is that I have configured two beans that implement the same interface and I have a third bean that has a property of that interface's type. I inject the property using a config property. So, assuming RemoteDataSource and LocalDataSource implement IDataSource and dao1 has a property of type IDataSource, my XML config might look like this:
<bean id="datasource1" class="com.foo.RemoteDataSource">
<property name="url">${url}</property>
</bean>
<bean id="datasource2" class="com.foo.LocalDataSource">
<property name="path">${filepath}</property>
</bean>
<bean id="dao1" class="com.foo.MyDAO">
<property name="dataSource">${datasource}</property>
</bean>
With url, filepath and datasource being defined in an included properties file. We are now making a push for annotation-driven configuration and I'm not sure how to annotate my dao to put the data source configured in the property file. I want to do something like this, but it is evidently not allowed:
@Autowired
@Qualifier("${datasource}")
public void setDataSource(IDataSource datasource) {...}
Recently I have been asked one question that in a singularly linked list how do we go to the middle of the list in one iteration.
A --> B --> C --> D (even nodes)
for this it should return address which points to B
A --> B --> C (odd nodes)
for this also it should return address which points to B
There is one solution of taking two pointers one moves one time and other moves two times but it does not seem working here
LinkedList p1,p2;
while(p2.next != null)
{
p1 = p1.next;
p2 = p2.next.next;
}
System.out.print("middle of the node" + p1.data); //This does not give accurate result in odd and even
Please help if anyone has did this before.
Without accessing private API's to get Content URI's, etc. for SMS, how are we expected to query this data? I am currently in the process of writing my own SMS app and I want to stay as compatible as possible. Without storing the information myself in my own database (such that I can store the text messages so that other programs can access the data when/if they delete my app) and without using private API's how the heck are we suppose to query SMS data?
I have a listview called quotesList, and I am trying to use an adapter to put information in it.
Here is my code:
ListView listView = (ListView) findViewById(R.id.quotesList);
String[]values={"Android","iOS","Windows Phone","Other Stuff"};
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, android.R.id.text1,values);
listView.setAdapter(adapter);
The only error that Eclipse shows is in the listView.setAdapter(adapter) line. The bold represents where the red squiggly is.
Syntax error on token "adapter", VariableDeclaratorId expected after this token
The period after listView gives an error as well, but I'm pretty sure its just related to the other error, as its a syntax error.
Syntax error on token(s), misplaced construct(s)
Thanks in advance!
I have a list management appliaction that stores its data in a many-to-many relationship database.
I.E. A note can be in any number of lists, and a list can have any number of notes.
I also can export this data to and XML file and import it in another instance of my app for sharing lists between users. However, this is based on a legacy system where the list to note relationship was one-to-many (ideal for XML).
Now a note that is in multiple lists is esentially split into two identical rows in the DB and all relation between them is lost.
Question: How can I represent this many-to-many relationship in a simple, standard file format? (Preferably XML to maintain backwards compatibility)
Currently, my code would construct the GWT form, which user would submit directly to openId (or any authenticaiton service). Such a method works fine.
However, what if I had the gwt page server access the OpenID provider, is there a way/strategy for the server to mediate authentication between its client and the auth provider?
I wish to know the answers with respect to
GAE as the proxy
and, regardless if GAE or Tomcat is the intended proxy, answers wrt
Google Accounts
OpenID
OAuth
If so, it would be wonderful if someone could describe the installation strategy.
I have not found any answer for my problem, so I need your help ...
I have an LinearLayout which I want to be clickable in order to lunch another activity. So I implement an onClickListener to it.
I created an selector for this LinearLayout in order that what someone click on it, the background change.
I just don't understand that :
If my LinearLayout doesn't have android:clickable="true" in the xml, I'm able to click on it and get what I want but the selector doesn't work.
If I remove this line, it is the opposite .. the selector work but not the onClick event.
So, can anyone can explain me why ?
Just in case, here is my the content of my selector file :
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/btn_restaurants_background_state_pressed" android:state_pressed="true"></item>
<item android:drawable="@drawable/btn_restaurants_background_state_pressed" android:state_focused="true"></item>
<item android:drawable="@drawable/btn_restaurants_background_state_pressed" android:state_selected="true"></item>
<item android:drawable="@drawable/btn_restaurants_background_state_normal"></item>
</selector>
Thanks you in advance