Monday, May 5, 2014

[Android] Gmail attachments playing music Permission Denial


I heard google upgraded safety certification Gmail, so com.google.android.gm.permission.READ_GMAIL access was denied.
Some people solved this problem? My player can be built into the system, not a third party, do not know what the solutions. Hurry! ! ! ! ! ! ! ! ! Seek expert help.

Here is the log:

WARN / ActivityManager (254): Permission Denial: opening provider com.google.android.gm.provider.MailProvider from ProcessRecord {415f9390 4120: com.sonyericsson.music/10037} (pid = 4120, uid = 10037) requires com.google . android.gm.permission.READ_GMAIL or com.google.android.gm.permission.WRITE_GMAIL
08-27 15:42:07.948: ERROR / NotificationService (254): Ignoring notification with icon == 0: Notification (contentView = null vibrate = null, sound = null, defaults = 0x0, flags = 0x62)
08-27 15:42:07.968: INFO / SemcMusicPlayer (4120): wakeLock isHeld: true
ERROR / MediaPlayer (4120): Uri is content :/ / gmail-ls/wqftest1 @ gmail.com/messages/24/attachments/0.1/BEST/false
08-27 15:42:07.978: DEBUG / MediaPlayer (4120): http youtube = false, scheme = content
08-27 15:42:07.978: DEBUG / MediaPlayer (4120): Couldn't open file on client side, trying server side
08-27 15:42:07.978: WARN / MediaPlayerService (121): setDataSource (content :/ / gmail-ls/wqftest1 @ gmail.com/messages/24/attachments/0.1/BEST/false)
08-27 15:42:07.978: ERROR / MediaPlayerService (121): Couldn't open fd for content :/ / gmail-ls/wqftest1 @ gmail.com/messages/24/attachments/0.1/BEST/false
08-27 15:42:07.978: ERROR / MediaPlayer (4120): Unable to to create media player
08-27 15:42:07.978: WARN / ActivityManager (254): Permission Denial: opening provider com.google.android.gm.provider.MailProvider from ProcessRecord {415f9390 4120: com.sonyericsson.music/10037} (pid = 4120 , uid = 10037) requires com.google.android.gm.permission.READ_GMAIL or com.google.android.gm.permission.WRITE_GMAIL
08-27 15:42:07.978: WARN / ActivityManager (254): Permission Denial: opening provider com.google.android.gm.provider.MailProvider from (null) (pid = 121, uid = 1013) requires com.google. android.gm.permission.READ_GMAIL or com.google.android.gm.permission.WRITE_GMAIL
08-27 15:42:07.988: INFO / SemcMusicPlayer (4120): Received a CallState event State:. 0
08-27 15:42:07.988: WARN / ActivityManager (254): Permission Denial: opening provider com.google.android.gm.provider.MailProvider from ProcessRecord {415f9390 4120: com.sonyericsson.music/10037} (pid = 4120 , uid = 10037) requires com.google.android.gm.permission.READ_GMAIL or com.google.android.gm.permission.WRITE_GMAIL
08-27 15:42:07.998: ERROR / SemcMusicPlayer (4120): Error code: 0 setDataSource failed:. Status = 0x80000000
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Wood someone to see it? Anxious ah
Reply:
Join
inside the AndroidManifest.xml


Reply:
Plus too, does not work, look at this link http://productforums.google.com/forum/ #! Msg/gmail/XD0C4sw9K7U/LpNXxFNnfgc
, Google improve Gmail's permission, even though the addition of a third party apk uses-permission android: name = "com.google.android.gm.permission.READ_GMAIL" />
Also do not have access. Apk should be able to access the system level, but I do not know how I became a system-level apk apk
reference to the second floor of the reply:.
inside the AndroidManifest.xml Join



Reply:
Does not work, has been coupled with the permission, or there is a problem. Look at the following link http://productforums.google.com/forum/ #! Msg/gmail/XD0C4sw9K7U/LpNXxFNnfgc
google improved their authority to prevent the use of a third party apk , should be allowed only system-level apk visit, I do not know how to make this apk become system-level.

reference to the second floor of the reply:
join
inside the AndroidManifest.xml


Reply:
Anyone know?
Reply:
Did not understand. . . .
Reply:
Will the landlord did not solve the
Reply:
In Android.mk in the LOCAL_CERTIFICATE: = platform
This is the right system ap

android GridView prohibited item to get focus, seeking big cow!


Recently made a set-top box applications, demand is horizontal scroll two rows of data;
My solution is:
HorizontalScrollView + GridView, but if you use the focus control scrolling, it must prohibit the item gets the focus, so to gridview set myGridView.setDescendantFocusability (ViewGroup.FOCUS_AFTER_DESCENDANTS);
But there is a problem after scrolling when scrolling to the end, the focus away from gridview then came in, the focus will jump directly to each item in the first, but not into the nearest item, what is the reason?
Been tested, regardless of whether there are sets of rolling out GridView control, even if it is a separate GridView, as long as the set myGridView.setDescendantFocusability (ViewGroup.FOCUS_AFTER_DESCENDANTS);
So the focus away from the GridView, then come all the direct jump to the first item inside, rather than entering from outside Button recent item.
Solving! How to solve this problem?
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->

Android call urlConnectoin.getInputStream error java.io.EOFException



First of all, this code is read directly Baidu Baike my html page in Android using the program, and then to the analytical procedure, the problem now is that it has not yet begun to read, it has been given a!
As follows:

This is the error message:

07-05 23:31:36.827: W / System.err (2847): java.io.EOFException
07-05 23:31:36.835: W / System.err (2847): at java.util.zip.GZIPInputStream.readFully (GZIPInputStream.java: 214)
07-05 23:31:36.835: W / System.err (2847): at java.util.zip.GZIPInputStream . (GZIPInputStream.java: 81)
07-05 23:31:36.835: W / System.err (2847): at java.util.zip.GZIPInputStream . (GZIPInputStream.java: 64)
07-05 23:31:36.842: W / System.err (2847): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.initContentStream (HttpURLConnectionImpl.java: 539)
07-05 23:31:36.842: W / System.err (2847): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.retrieveResponse (HttpURLConnectionImpl.java: 1046)
07-05 23:31:36.842: W / System.err (2847): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream (HttpURLConnectionImpl.java: 512)
07-05 23:31:36.842: W / System.err (2847): at com.avin.priney.utils.GBKGetter.getKnowledgeByWord (GBKGetter.java: 378)
07-05 23:31:36.842: W / System.err (2847): at com.avin.priney.android.AnswerStrategy.getFinalAnswer (AnswerStrategy.java: 265)
07-05 23:31:36.842: W / System.err (2847): at com.avin.priney.android.PrineyMainActivity.getResultTxtByQuestionTxt (PrineyMainActivity.java: 272)
07-05 23:31:36.850: W / System.err (2847): at com.avin.priney.android.PrineyMainActivity.onClick (PrineyMainActivity.java: 145)
07-05 23:31:36.850: W / System.err (2847): at android.view.View.performClick (View.java: 2485)
07-05 23:31:36.850: W / System.err (2847): at android.view.View $ PerformClick.run (View.java: 9090)
07-05 23:31:36.850: W / System.err (2847): at android.os.Handler.handleCallback (Handler.java: 587)
07-05 23:31:36.850: W / System.err (2847): at android.os.Handler.dispatchMessage (Handler.java: 92)
07-05 23:31:36.850: W / System.err (2847): at android.os.Looper.loop (Looper.java: 130)
07-05 23:31:36.858: W / System.err (2847): at android.app.ActivityThread.main (ActivityThread.java: 3859)
07-05 23:31:36.858: W / System.err (2847): at java.lang.reflect.Method.invokeNative (Native Method)
07-05 23:31:36.858: W / System.err (2847): at java.lang.reflect.Method.invoke (Method.java: 507)
07-05 23:31:36.858: W / System.err (2847): at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java: 839)
07-05 23:31:36.858: W / System.err (2847): at com.android.internal.os.ZygoteInit.main (ZygoteInit.java: 597)
07-05 23:31:36.858: W / System.err (2847): at dalvik.system.NativeStart.main (Native Method)


The following code segment posted the problem:

String webUrl = "http://baike.baidu.com/searchword/?word =" + nCode + "& pic = 1";
/ / Built-in Wikipedia page address
String contentUrl = "http://baike.baidu.com";
BufferedReader br = null;
String backLine = null;
URL url = null;
try {
url = new URL (webUrl);

Log.d ("Avin", "webUrl going open ...");

URLConnection conn = url.openConnection ();

Log.d ("Avin", "webUrl opened ...");

Log.d ("Avin", "the question is ->" + question);

/ / Display exception information is being given this line
br = new BufferedReader (new InputStreamReader (conn.getInputStream ()));


backLine = br.readLine ();

Log.d ("Avin", backLine);
int clmindex = 1;
while (backLine! = null) {
backLine = br.readLine ();
/ *
if (clmindex == 20) {
/ / Track to the target page where the line out of the loop
break;
}
* /
System.out.println (clmindex + "->" + backLine);
clmindex + +;
}
br.close ();


br = new BufferedReader (new InputStreamReader (conn.getInputStream ()));
This line error! Check the day's data, that is not progress,
This exception means that the file is read ends abnormally, the error status is returned, but the lines of code to see the error in this case it has not started to read the data, how it will end abnormally, baffled!

This code is placed JavaProject in on the right, on my cell phone will not work!


Desperation, hereby to other experts answer!
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Attention, just have encountered this problem seems to be conn.getInputStream () wrong
Reply:
My program also seemed to buffer = new BufferedReader (new InputStreamReader (urlConn.getInputStream ()));, did not even run to catch a direct
Reply:
Yes, it is unusual when getInputStream! Previously used properly, after a few days on the bad, somehow, the feeling is not the problem of the program, the site seems to be what has changed, or is the web server directly shielding the tragedy! , Experts expect! And thank you for helping!
Reply:
I saw on stackoverflow, someone is
this solution forSystem.setProperty ("http.keepAlive", "false");

And we also verified, and really easy to use.
Reply:
Alas, I have encountered. . .
Reply:
I have encountered this problem, the landlord is how you solve?
Reply:
Experts expect to solve!
Reply:
Also encountered this problem, the landlord to solve it?
Reply:
Need to access the network configuration mainFest.xml file permissions

Reply:
Upstairs No, I have been added, or an error
Reply:
The landlord did not seek to get advice
Reply:
references, 4th Floor bonwei reply:
on stackoverflow I see someone is
this solution forSystem.setProperty ("http.keepAlive", "false");

And we also verified, and really easy to use.

Where does this add?
Reply:
The same problem, help ah
Reply:
Solve it?
keepAlive
Reply:
The same problem Yeah ~ ~ ~ I hope the experts rescue!
Reply:
I have encountered this problem, ask the landlord to solve it?
Reply:
So many people want to grab Baidu Baike page Yeah, I need this feature, but also encountered this problem, sometimes looks like a line, sometimes throwing the exception, strange
Reply:
There are so many people have to see this stuff and anguish.
I sent a link to it, according to this method can get rid
http://blog.sina.com.cn/s/blog_6c60678b0101e847.html
Reply:
In fact, the problem is that the thread
Reply:
Yet to find a solution
Reply:
Feeling is a web source more time will be ringing off the hook, if less then normal operation, do not know why

How to turn off all log Andrews systems??


Such as the title, now encounter a problem in their own equipment installed on the application of a third party, but the applications have problems, too much log information about printing, resulting in a serious impact this program to run the system, ultra-high memory share.

The problem is that there is no way (or input a command) can print all the log information systems are turned off, or just turn off debug level, it will be open to err level? ?
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
You can set the level log of ah
Reply:
cited a floor huxiweng reply:
you can set the level log of ah


I mean control of third-party applications log Print
Reply:
Modify the ROM
Reply:
adb shell
getprop | grep log

Output information to see if there's a similar log enable disable attribute directly modify any property values ​​setprop then restart
Reply:
Add that phone to
rootsu to the root user
Reply:
grep log nothing, getprop from start to finish where I read it again, did not seem to find it
< img alt = "" src = "http://img.bbs.csdn.net/upload/201403/31/1396250476_587351.jpg" />
Reply:
references, 5th Floor ncepu307 reply:
add that phone to root
su to the root user

This is getprop information on my device, it looks like there is no
Reply:
reference to the third floor DrSmart reply:
modified ROM of

Where to modify the ROM?
Reply:
Command: adb logcat *: E
Print only Error and fatal error of log
Reply:
reference to the 9th floor dxjwolf reply:
command: adb logcat *: E
Error and fatal error only print the log

I do not mean that.
logcat just log information is displayed, even if you do not log, there are still a steady stream of information output outside, but is not showing it.
So I want to do is how to put this log from the source stopped, do not want foreign output, similar to its own program code Log.d like commenting,
How this should be done? There is no way
Reply:
Do you mean to put this apk's log output off?
Try this
http://blog.csdn.net/jiese1990/article/details/21752159
Reply:
reference to the 11th floor dxjwolf reply:
you mean to put this apk's log output off?
Try this
http://blog.csdn.net/jiese1990/article/details/21752159

Thank you, though this is not the answer to my problem, but he solved my another question, thank you, and stick to the sub knot

android system.exit (0) to exit the program in question


1, system.exit (0) to exit the contents of a process. If there is a thread in an activity so that he could exit. But in this activity if you start a service, and then start a thread in the service, then he can not shut down the service and this thread. This is also why the service is not started this process yet?

Service Code
public class TestService extends Service {
private boolean isCur = true;
@ Override
public IBinder onBind (Intent intent) {
/ / TODO Auto-generated method stub
return null;
}
@ Override
public void onCreate () {
/ / TODO Auto-generated method stub
super.onCreate ();
new Thread () {
public void run () {
while (isCur) {
System.out.println ("print out ------------------------------------");
try {
Thread.sleep (5000);
} Catch (InterruptedException e) {
/ / TODO Auto-generated catch block
e.printStackTrace ();
}
}
};
.} Start ();
}
@ Override
public void onDestroy () {
/ / TODO Auto-generated method stub
isCur = false;
System.out.println ("close ------------------------------------------ --------------- ");
super.onDestroy ();

}

}
/ / Activity code
public class MainActivity extends Activity {

@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);
}
public void close (View view) {

System.exit (0);
}
public void startSer (View view) {
Intent intent = new Intent ("analisis.resplay.voice.testservice");
startService (intent);
}
@ Override
protected void onPause () {
/ / TODO Auto-generated method stub
super.onPause ();

}

@ Override
public boolean onCreateOptionsMenu (Menu menu) {
/ / Inflate the menu; this adds items to the action bar if it is present
.getMenuInflater () inflate (R.menu.main, menu);.
return true;
}

}


Online seek to explain the great God
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
System.exit (0); close the main thread, the service to start another thread on the main thread does not automatically turn off after a thread to finish executing. In fact, your question is a conclusion.
Reply:
cited a floor u012535657 reply:
System.exit (0); close the main thread, the service does not start another thread on the main thread, After execution threads automatically close. In fact, your question is a conclusion.


My question is actually system.extit (0) can close those things, why he can not shut down the service, the service is run in the main thread. And the same process, but he did not shut down.
Reply:
In Java, you can use this method to end the whole application in android, this method can also be turned off Activity, but the kind of situation needs attention: the service if it is open and Activity bound together, when the Activity is kill off service also will be to kill off; If the service does not bind together and Activity, when the Activity is to kill off, service was not immediately kill off, I do not know LZ can understand.
Reply:
reference to the third floor u012535657 reply:
in Java can use this method to end the whole application in android, this method can also be turned off Activity, but there case Note: If the service is open and Activity bound together, when the Activity is to kill off, service also will be to kill off; If the service does not bind together and Activity, when the Activity is kill off service is not immediately kill off, I do not know LZ can understand.
that is, if it is bindService service will only be activated if it is by intent KILL out the need to manually stop start
Reply:
Meaning of existence is service running in the background, if it will be destroyed along with the main thread that their meaning is basically gone! If you want to close it manually in ondestory inside!
Reply:
reference to the third floor u012535657 reply:
in Java can use this method to end the whole application in android, this method can also be turned off Activity, but there case Note: If the service is open and Activity bound together, when the Activity is to kill off, service also will be to kill off; If the service does not bind together and Activity, when the Activity is kill off service is not immediately kill off, I do not know LZ can understand.
I know this conclusion, but also have done, but now understand clearly.
system.exit (0) off the virtual machine memory, that is, kill off the current process. And why start the service will not be killed because of a service is the default start is to start a process to run. So with such a conclusion is not all of the activity or service they are set in the same process if it can system.exit (0) completely out of the system? Attempt
Reply:
I do not understand, service and activity has always been in the same thread, activity hung up, should have hung up the fishes service, but did not. . .
Reply:
After the activity if not bind together with the service, then call system.exit (0) in the activity, the entire process really quit immediately, but you carefully watch what log system, there will be a schedule restart your yingyongming 5000ms later, that is, said the system will reboot your service, you can be a test test

The new version of android sdk import procedures


Download a seemingly new version sdk + adt
Each time a new project will automatically generate a appcompat_v7 package,
Now, I imported the previous android package, this will happen, I ask how to solve
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Modify the project project.properties file under the target = android-15, can be changed to fit in your api, you try to save into 14, then 15 and then changed again if the error preservation, hope you can help
Reply:
Should be a version can not be cast, but there should be no impact on the above red bar,,,
Reply:
cited a floor u012365618 reply: project.properties under
modify the project file in the target = android-15, you can fit into the api, you changed to 14 to try to save, if error then changed after 15 and then save, I hope to help you

Before 19, 1514 will not change ah
Reply:
reference to the second floor heaimnmn reply:
version should not be forced to convert, but there should be no effect on red above it,,,

Influential ah, you can not run
Reply:
references, 4th Floor huhuint reply:
Quote: references to the second floor heaimnmn reply:

Should be a version can not be cast, but there should be no impact on the above red bar,,,

Influential ah, you can not run
< / fieldset> then you will directly create 14 bars, 19 can not be converted down
Reply:
Some estimates are missing dependencies, this version of Android you have too much of it
Reply:
reference to the 6th floor zhang1317725 reply:
estimated to be missing some of the dependencies, which version of Android you have too much of it
< br />
Yes, ah, it seems I do not fit with the new version
Reply:
You can right-click the project name - attribute - android - add a appcompt-v7 associated dependencies on OK to try

Reply:
You
within the project's main configuration file ANDROIDSMAIN.XMLThe version number changed to 19. Additionally COPY gen directory from the backup project in
File under overwrite an existing file, or create a new project from a new, removable internal
File under gen directory covering gen directory you have problems first project under the content.

Reply:
reference to the 8th floor u014081087 reply:
you can right-click the project name - attribute - android - add a appcompt-v7 associated dependencies on OK a try

Not ok ah
Reply:
I also encountered the same problem, solving

Custom ArrayAdapter initialization can not be displayed, add new data duplication Show all


HI, everybody Andrews research engineer, ask questions as

Imitation online custom written a ArrayAdapter, as follows:
 
mport java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import cn.com.ccxe.bean.Article;
import cn.com.ccxe.bean.ComplexMessage;
import cn.com.ccxe.message.R;
import cn.com.ccxe.util.AsyncImageLoaderTask;

public class MessageArrayAdapter extends ArrayAdapter {

private int resourceId;
Context mContext;
LayoutInflater mLayoutInflater;


public MessageArrayAdapter (Context context, int textViewResourceId, List cms) {
super (context, textViewResourceId, cms);
this.resourceId = textViewResourceId;
mContext = context;
mLayoutInflater = LayoutInflater.from (context);
}

@ Override
public View getView (int position, View convertView, ViewGroup parent) {
ComplexMessage cm = getItem (position);

View view;
if (convertView == null) {
view = mLayoutInflater.inflate (resourceId, parent, false);
} Else {
view = convertView;
}

LinearLayout linearLayout = (LinearLayout) view.findViewById (R.id.messageArrayAdapterLinerlayout);
Article [] arts = cm.getNews () getArticles ();.
if (arts! = null && arts.length == 1) {
/ / If there is only one message
} Else {
/ / If multiple messages
for (int i = 0; i if (i == 0) {
Article art = arts [i];
FrameLayout frameLayout = new FrameLayout (mContext);
FrameLayout.LayoutParams frameLayoutParams = new FrameLayout.LayoutParams (FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
frameLayoutParams.leftMargin = 20;
frameLayoutParams.rightMargin = 20;
frameLayout.setLayoutParams (frameLayoutParams);
ImageView iv = new ImageView (mContext);
android.view.ViewGroup.LayoutParams ivLayoutParams = new android.view.ViewGroup.LayoutParams (linearLayout.getWidth (), linearLayout.getWidth () / 2);
iv.setLayoutParams (ivLayoutParams);
iv.setTag (art.getPicurl ());
new AsyncImageLoaderTask () execute (art.getPicurl (), iv);.
TextView tv = new TextView (mContext);
android.view.ViewGroup.LayoutParams tvLayoutParams = new android.view.ViewGroup.LayoutParams (linearLayout.getWidth (), linearLayout.getWidth () / 4);
tv.setLayoutParams (tvLayoutParams);
tv.setText (art.getTitle ());
frameLayout.addView (iv);
frameLayout.addView (tv);
linearLayout.addView (frameLayout);
} Else {
}
}
}
return view;
}

}



Then, in the Activity call as follows:
 

DatabaseHelper dbHelper = DBUtil.getDatabaseHelper (MainActivity.this);
Cursor c = null;
try {
SQLiteDatabase sqliteDatabase = dbHelper.getReadableDatabase ();
c = sqliteDatabase.rawQuery ("SELECT * FROM message ORDER BY _id DESC limit 0,10", new String [] {});
while (c.moveToNext ()) {
int _id = c.getInt (c.getColumnIndex ("_id"));
idMax = idMax> _id idMax: _id;
?idMin = idMin> _id _id:? idMin;
String message = c.getString (c.getColumnIndex ("message"));
Gson g = new Gson ();
ComplexMessage cm = g.fromJson (message, new TypeToken () {} getType ().);
mListItems.add (cm);
}


} Catch (Exception e) {
Log.e (MainActivity.class.toString (), e.toString ());
} Finally {
if (c! = null) {
c.close ();
}
}

mAdapter = new MessageArrayAdapter (this, R.layout.list_view1_item, mListItems);
/ / You can also just use setListAdapter (mAdapter)
actualListView.setAdapter (mAdapter);
mAdapter.notifyDataSetChanged ();
mPullRefreshListView.getRefreshableView () setSelection (mAdapter.getCount () -1);.



Discovery opens the application, even if the data is not displayed.
The MainActivity realized OnScrollListener, made an asynchronous thread, load the data when the finger paddling when they can show up, but every time it loads all the data is displayed, not only demonstrate the new additions

 
private class GetDataTask extends AsyncTask {

@ Override
protected String [] doInBackground (Void. .. params) {

return null;
}

@ Override
protected void onPostExecute (String [] result) {
DatabaseHelper dbHelper = DBUtil.getDatabaseHelper (MainActivity.this);
SQLiteDatabase sqliteDatabase = dbHelper.getReadableDatabase ();
Cursor c = sqliteDatabase.rawQuery ("select * from message where _id int count = c.getCount ();
try {
if (c.getCount ()> 0) {
while (c.moveToNext ()) {
int _id = c.getInt (c.getColumnIndex ("_id"));
idMax = idMax> _id idMax: _id;
?idMin = idMin> _id _id:? idMin;
String message = c.getString (c.getColumnIndex ("message"));
Gson g = new Gson ();
ComplexMessage cm = g.fromJson (message, new TypeToken () {} getType ().);
mListItems.addFirst (cm);
}

}
} Catch (Exception e) {
Log.e (MainActivity.class.toString (), e.toString ());
} Finally {
c.close ();
}
mAdapter.notifyDataSetChanged ();
/ / / / Call onRefreshComplete when the list has been refreshed.
mPullRefreshListView.onRefreshComplete ();
mPullRefreshListView.getRefreshableView () setSelection (count-1);.
super.onPostExecute (result);
}
}



Please advice, find a day do not know where the problem.


<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
See friends said in the main thread which can not have network operations or database operations, so that a few lines of code to get the data into several DEMO initialization data from the database in the Activity, found that this can show up.

So you can think straight points to open the display data in the database should be how to operate it? Also use asynchronous way?
Reply:
The most critical is that when clicking refresh, why always repeat refresh all data?
Reply:
There is no master come urged Online.
Reply:
Partial refresh with notifyDataSetChanged
Reply:
4th Floor, positive solution, add your adapter data list, with notifyDataSetChanged, achieved partial refresh
Reply:
mAdapter.notifyDataSetChanged ();
Code related to this method ah

Bluetooth development issues


The newly developed program can run on Bluetooth version 2.0, but put on 3.0, accept and connect will be reported connection is not created errors, ask God how to solve large
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Their top trying to solve ah

android. setText mistake, find a lot of answers still do not know why


android: orientation = "vertical"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: background = "# C7EDCC">

android: id = "@ + id/text1"
android: layout_width = "fill_parent"
android: layout_height = "wrap_content"
android: text = "text1"
android: textSize = "30sp"
android: textColor = "# 8B3A3A"
android: gravity = "right"
android: layout_marginTop = "15px"
/>
android: id = "@ + id/text2"
android: layout_width = "fill_parent"
android: layout_height = "wrap_content"
android: layout_marginTop = "10dip"
android: textColor = "# 000000"
android: textSize = "19sp"
android: text = "text2"
/>


public class MainActivity extends Activity {
private TextView myTxt;
@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);
/ / ----------------------------
myTxt = (TextView) findViewById (R.id.text2);
myTxt.setText ("ajfijwofjowiejfoiewoi");
/ / ----------------------------
if (savedInstanceState == null) {
getFragmentManager (). beginTransaction ()
. Add (R.id.container, new PlaceholderFragment ()) commit ();.
}
}
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
myTxt is null
Reply:
That amount is how to write, where I did not write Yeah
Reply:
reference to the second floor lsTMango reply:
amount that is how to write, where I did not write Yeah

Either do not fragment, or the processing into Fragment in myTxt
Reply:
reference to the third floor hjywyj reply:
Quote: references to the second floor lsTMango reply:

That amount is how to write, where I did not write Yeah

Either do not fragment, or will myTxt processing into Fragment Lane

- How to get solve novice
Reply:
Great God soon appear online Yeah. . .
Reply:
reference to the third floor hjywyj reply:
Quote: references to the second floor lsTMango reply:

That amount is how to write, where I did not write Yeah

Either do not fragment, or will myTxt processing into Fragment Lane

On the inside or have been deleted or not try! ! ! !
Reply:
Your R.id.container in there? ? ? Code did not paste the full right?
Reply:
reference to the 7th floor lxwwd reply:
your R.id.container in there? ? ? Code did not paste the full right?

package com.example.zno4_textview2;



import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build;
/ / ---------------------------------
import android.graphics.Color;
import android.widget.TextView;
/ / ---------------------------------
public class MainActivity extends Activity {
private TextView myTxt;
@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);

if (savedInstanceState == null) {
getFragmentManager (). beginTransaction ()
. Add (R.id.container, new PlaceholderFragment ()) commit ();.
}
/ / ----------------------------
myTxt = (TextView) findViewById (R.id.text2);
myTxt.setText ("ajfijwofjowiejfoiewoi");
/ / MyTxt.setTextColor (Color.BLUE);
/ / MyTxt.setTextSize (19);
/ / ----------------------------
}

@ Override
public boolean onCreateOptionsMenu (Menu menu) {

/ / Inflate the menu; this adds items to the action bar if it is present
.getMenuInflater () inflate (R.menu.main, menu);.
return true;
}

@ Override
public boolean onOptionsItemSelected (MenuItem item) {
/ / Handle action bar item clicks here. The action bar will
/ / Automatically handle clicks on the Home / Up button, so long
/ / As you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId ();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected (item);
}

/ **
* A placeholder fragment containing a simple view.
* /
public static class PlaceholderFragment extends Fragment {

public PlaceholderFragment () {
}

@ Override
public View onCreateView (LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate (R.layout.fragment_main, container,
false);

return rootView;
}
}

}

Reply:
reference to the 7th floor lxwwd reply:
your R.id.container in there? ? ? Code did not paste the full right?

Could it be I was under the Eclipse version too high?
Reply:
 

/ **
* A placeholder fragment containing a simple view.
* /
public static class PlaceholderFragment extends Fragment {

public PlaceholderFragment () {
}
private TextView myTxt;
@ Override
public View onCreateView (LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate (R.layout.fragment_main, container,
false);
myTxt = (TextView) rootView.findViewById (R.id.text2);
myTxt.setText ("Hello World!");
return rootView;
}
}

Reply:
reference to the 10th floor hjywyj reply:
 

/ **
* A placeholder fragment containing a simple view.
* /
public static class PlaceholderFragment extends Fragment {

public PlaceholderFragment () {
}
private TextView myTxt;
@ Override
public View onCreateView (LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate (R.layout.fragment_main, container,
false);
myTxt = (TextView) rootView.findViewById (R.id.text2);
myTxt.setText ("Hello World!");
return rootView;
}
}
Thank you ah finally, it seems that the next code to be written there, although now understand this PlaceholderFragment is used to do

Not familiar with programming for android, ask two questions


Not familiar with programming for android, ask two questions
First, read and write files, how to read and write the specified location, such as a file has 1024 bytes, I want to read only the first 500 bytes to 600 bytes how to do, is not necessarily to read 600 bytes and then throw away the first 500 bytes, which is not what I want, for example, if the file has 2G, 2G wholly impossible to read out of it
Second, the layout is definitely not recommended, but I want to run after the program is able to set my interface, want to put the button onto the place, it could change the button layout is definitely replace what way. (Originally under 2.3 can be used with absolute layout, now at 4.2 operating under the same code to die, is not the absolute layout is no longer supported)
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
You can add your own plus a logic output file stream
2 You can use multiple nested layout
Reply:
A file stream that generally seek to know this stuff.
He did not so used on android. You simply check on it.
Reply:
Thanks to both answers, but for the second question, after running to change the position of the controls, I do not know how to use nested, it should be very complicated, I am currently using a relative layout, set up each control ID, the user interface settings , remember to save the controls next to the controls, which can basically achieve the goal, but still not as good as the layout is definitely convenient, but restrictions are also great, do not know how to think GOOGLE, with code layout, the layout is definitely better than any relative layout, performance or, how not support it? The first question, I use FileOutputStream and FileInputStream, did not find a seek method or setseek
Reply:
1. FileInputStream.skip is to use seek to achieve.
Alternatively, you can use to achieve your needs
RandomAccessFile
2 with FrameLayout realize what's the problem?
Reply:
reference to the third floor fieldisme reply:
thank two answers, but for the second question, after running to change the position of the controls, I do not know how to use nested, it should be very complicated, I am currently using a relative layout, set up each control ID, after the user interface settings, remember to save the controls next to the control, which can basically achieve the goal, but still not as good as the layout is definitely convenient, but restrictions large, do not know how to think GOOGLE, with code layout, the layout is definitely better than any relative layout, performance is good, how can not support it? The first question, I use FileOutputStream and FileInputStream, did not find seek or setseek method

Unless you just absolutely layout application screen adaptation, and now so many android phones, various screen sizes, resolutions. Absolute layout barely use.
Reply:
references, 4th Floor youngc527 reply:
1 FileInputStream.skip is to use seek to achieve.
Alternatively, you can use to achieve your needs
RandomAccessFile
2 with the realization of what's the problem?


I am a novice, the original will be c + +, just turn around, thank you for your ideas, but I checked the FrameLayout, all placed in the layout of the controls are in accordance with the level of the stack in the upper left corner of the screen. After covering the front of the controls add to the mix of control. In FrameLayout layout, the definition of the location of any space-related properties are meaningless. I do not know how to use this stuff, I just want to define the location of properties that it actually meaningless. Also, my original phone is version 2.3, 4.2 out change, and when the absolute layout think so, get pixel screen before each run, the location information stored in my control is a logical value, the screens average into 1000 points, on a different phone, the screen pixel by 1000, the value obtained by multiplying the coordinates of my control, the size of the value, and then show up, there should not have different phone display is not the same situation
Reply:
lz look at it relative layout and linear layout
Reply:
1, the first question simply does not belong to Android development problem is the problem of Java IO streams, the landlord can see Java SE related knowledge. Well, the foundation is very important.

2, you can use a nested layout. Think the layout can be achieved with relative effect of what you said.
Reply:
The knot posted, youngc527 first question has been answered, the second question I have actually achieved relative layout, but more complex than absolute layout, but also larger than the absolute limit distribution, relative layout controls only need to save their left , top, width, height on the line, relative to the layout have to remember what the controls around, what is the relationship with the surrounding controls, is very complex, it issued the complaint.
Reply:
reference to the 6th floor fieldisme reply:
Quote: references to the 4th floor youngc527 reply:

1. FileInputStream.skip is to use seek to achieve.
Alternatively, you can use to achieve your needs
RandomAccessFile
2 with the realization of what's the problem?


I am a novice, the original will be c + +, just turn around, thank you for your ideas, but I checked the FrameLayout, all placed in the layout of the controls are in accordance with the level of the stack in the upper left corner of the screen. After covering the front of the controls add to the mix of control. In FrameLayout layout, the definition of the location of any space-related properties are meaningless. I do not know how to use this stuff, I just want to define the location of properties that it actually meaningless. Also, my original phone is version 2.3, 4.2 out change, and when the absolute layout think so, get pixel screen before each run, the location information stored in my control is a logical value, the screen average into 1000 points, on a different phone, the screen pixel by 1000, the value obtained by multiplying the coordinates of my control, the size of the value, and then show up, there should not have different phone display is not the same situation


When using FrameLayout, child's layout_marginLeft, layout_marginTop, layout_gravity can be used to fulfill your needs

android how to build back-office services


Brother, beginner android software is ready to be the case, the background service is responsible for receiving socket information has been running the front desk to obtain information from multiple activity have changed socket, my question now is not going to build this background service, I checked a lot of information on how is the foreground or the background process and the principle of how to write ah, what the background communication, which I know, the problem is I do not know how to build service this file ah. Like the new activity is the file-> NEw-> acitivity on it, but there is no service in the New File option this way
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Direct to build a class extends Service.
Reply:
1 write a class extends Service, as
 
public class ExampleService extends Service {
}

2. AndroidManifest.xml declared Service
 



Read more android document suggested, refs: http://developer.android.com/
Reply:
2nd Floor positive solution.
1, direct new one Class inheritance Service
2, Statement Service
in the manifest file3, rewritten Service method.

FragmentTabHost a total of two labels, but not the lateral full screen


Layout code
 xmlns: tools = "http://schemas.android.com/tools" 
android: layout_width = "match_parent"
android: layout_height = "match_parent"
android: orientation = "vertical">

android: id = "@ + id / main_relayout"
android: layout_width = "match_parent"
android: layout_height = "wrap_content"
android: background = "@ drawable / titlebarbackground"
android: padding = "10dp">





java file
 

public class MainAct extends FragmentActivity {
private FragmentTabHost mTabHost;
TabWidget tabWidget;
Button tongbu;
ContactsApp app;


private SharedPreferences sp;


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


app = (ContactsApp) getApplication ();
app.cList = new ArrayList ();

bottomViwe = findViewById (R.id.all_relative);


/ / Label 1
View tabView1 = LayoutInflater.from (this). Inflate (R.layout.biaoqian1,
null);
/ / Label 2
View tabView2 = LayoutInflater.from (this). Inflate (R.layout.biaoqian2,
null);

tongbu = (Button) findViewById (R.id.mian_tongbu);

mTabHost = (FragmentTabHost) findViewById (android.R.id.tabhost);
mTabHost.setup (this, getSupportFragmentManager (), R.id.realtabcontent);

mTabHost.addTab (mTabHost.newTabSpec ("allcontacts"). setIndicator (tabView1),
AllContactsFragment.class, null);
mTabHost.addTab (mTabHost.newTabSpec ("recievecontacts"). setIndicator (tabView2),
RecentContactsFragment.class, null);
tabWidget = (TabWidget) findViewById (android.R.id.tabs);
mTabHost.invalidate ();

}

public boolean onKeyDown (int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_BACK)
{
if (findViewById (R.id.all_relative) == null) {
return super.onKeyDown (keyCode, event);
}
if (findViewById (R.id.all_relative). getVisibility () == View.VISIBLE) {
. findViewById (R.id.all_relative) setVisibility (View.GONE);
AllContactsFragment.adapter.unShow ();
return true;
}
return super.onKeyDown (keyCode, event);

}

return super.onKeyDown (keyCode, event);

}



}


There are two tabs in this tabhost buttons;
Two labels are two view, composed by the ImageView and TextView;
I do not know why the two tabs on the big screen is fully satisfied, solving
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Image problem, set background attribute on it, knot stickers

app off automatically solving


Write your own app, when running in the background, if you change the input method, it will automatically re-entering closed, which is why, ask for advice, give thought to.
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
You catch about global exception, writes the log to see what is wrong
Reply:
look abnormal
Reply:
cited a floor cclovescw reply:
you to capture about global exception, writes the log to see what is wrong
< br />Thank you.

Difficulties help: music player pause () after the start () error


Play Service in music, Pause, after performing mediaPlayer.pause () the music stops, the executive mediaPlayer.start when you want to play again () error, the program has been to determine the method to be run before:




Baidu still not been resolved for a long time, seeking guidance ah!
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
You can paste the full code
Reply:
Please use AIDL, you suspend a thread, and another thread started, will certainly be given, if you just write activity on the inside can not go wrong, you can try,,,
Reply:
Try calling player.start () before calling the next setDataSource () method and prepare ()
Reply:

Recommend a look at this, look at the document in each state to change this thing MediaPlayer each state
Reply:
To determine the next you start calling, posted the code too. You posted this code can be added to determine the current state of play in the front.
Reply:
reference to the third floor blovecat reply:
try to call before calling player.start () under setDataSource () method and prepare ()
< / fieldset>
Again calling setDataSource () that do not play from the beginning of what I need to play from where it was paused
Reply:
references, 4th Floor u014081087 reply:

Recommend a look at this, look at the document in each state to change this thing MediaPlayer each state

Read this document but for pause () the file directly execute start () on the line, but I run start () method on the error
Reply:
references, 5th Floor lxwwd reply:
you start to determine the next call, posted the code too. You posted this code can be added to determine the current state of play in the front.

When using the pause () method when the moratorium on the error with this almost Later, I applied a try-catch on the line, but again with the use of start () when you start on the error with try-catch, and the judge did not use the state of play

After connecting data via webservice, how to resolve or get data (soapObject parsing)


Took a few days and finally connected to the database, but a new problem has emerged it! Get out of the data contained anyType, String type as shown:
How I parse out? Gaoshoubangbangmang ah!
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
public static CenterInfo [] getWorkOn (SoapObject obj) {
CenterInfo [] info = null;
try {
if (obj.getPropertyCount ()> 1) {/ / a central information
int len ​​= obj.getPropertyCount () - 1;
info = new CenterInfo [len];
for (int i = 0; i SoapObject child = (SoapObject) obj.getProperty (i + 1);
String idStr = child.getPropertyAsString (0);
String content = child.getPropertyAsString (1);
String sender = child.getPropertyAsString (2);
String typeStr = child.getPropertyAsString (3);
String uId = child.getPropertyAsString (4);
String time = child.getPropertyAsString (5) ;/ / Time
long id = Long.parseLong (idStr);
int type = Integer.parseInt (typeStr);
info [i] = new CenterInfo (id, content, sender, type, uId, time);
}
}
} Catch (Exception e) {
e.printStackTrace ();
}
return info;
}
Reply:
How does this CenterInfo [] is what ah? Novice seeking advice do not understand, there getPropertyCount () is what? These are how to use?
Reply:
This error may be we do not quite understand, especially posted code, seeking advice:
MainActivity:
 public void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);
searchs = (Button) findViewById (R.id.search);
results = (TextView) findViewById (R.id.result);
searchs.setOnClickListener (new View.OnClickListener () {

@ Override
public void onClick (View v) {
String wsdUrl = "http://192.168.1.195:88/service1.asmx";
String method = "SelectAll";
Object result = SOAPUtil.doTransport (wsdUrl, method);
results.setText (result.toString ());

}
});
}

SoapUtil:
 public static Object doTransport (final String wsdUrl, final String webMethod) {
String nameSpace = "http://tempuri.org/";
SoapObject soapObject = new SoapObject (nameSpace, webMethod);
/ / SoapObject.addProperty (propertyInfo)
System.out.println ();
SoapSerializationEnvelope soapSerializationEnvelope = new SoapSerializationEnvelope (
SoapEnvelope.VER11);
soapSerializationEnvelope.bodyOut = soapObject;
soapSerializationEnvelope.dotNet = true;
soapSerializationEnvelope.setOutputSoapObject (soapObject);
HttpTransportSE httpTransportSE = new HttpTransportSE (wsdUrl);
String SOAP_ACTION = "http://tempuri.org/" + webMethod;
System.out.println (SOAP_ACTION);
try {
httpTransportSE.call (SOAP_ACTION, soapSerializationEnvelope);
System.out.println ("call end");
System.out.println (soapSerializationEnvelope.getResponse ());
if (soapSerializationEnvelope.getResponse ()! = null) {
SoapObject result = (SoapObject) soapSerializationEnvelope
. GetResponse ();
System.out.println (result);
return result;
}
} Catch (IOException e) {
System.out.println ("IOException");
e.printStackTrace ();
} Catch (XmlPullParserException e) {
e.printStackTrace ();
}
return null;


Is it because I put all the data in a textview toString inside out? I how to put the data in the listview and display only the data do not show others?
Reply:
/ / Convert the SoapObject (CenterInfo) an array of objects
public static CenterInfo [] getWorkOn (SoapObject obj) {
/ / Define array
CenterInfo [] info = null;
try {
/ / If the received information
if (obj.getPropertyCount ()> 1) {/ / a central information
/ / Calculate the maximum array subscript
int len ​​= obj.getPropertyCount () - 1;
/ / Initialize the array object is to open up an array of storage space
info = new CenterInfo [len];
/ / Iterate analytical SoapObject
for (int i = 0; i / / Get SoapObject object
SoapObject child = (SoapObject) obj.getProperty (i + 1);
/ / Values ​​
String idStr = child.getPropertyAsString (0);
String content = child.getPropertyAsString (1);
String sender = child.getPropertyAsString (2);
String typeStr = child.getPropertyAsString (3);
String uId = child.getPropertyAsString (4);
String time = child.getPropertyAsString (5) ;/ / Time
long id = Long.parseLong (idStr);
int type = Integer.parseInt (typeStr);
/ / Packaged as demand object (CenterInfo), into an array of resources
info [i] = new CenterInfo (id, content, sender, type, uId, time);
}
}
} Catch (Exception e) {
e.printStackTrace ();
}
return info;
}
Reply:
LZ, this object is the need to resolve the drops, not directly toString ...... Do you Know?
Reply:
Aware of the need to resolve ah, someone said to resolve soapObject, some say parse json, very puzzled not understand ......
In the end resolve what, how to resolve?
Reply:
Parsing the object you get what you get, ah resolve even on ah? Did you get the SoapObject to turn into other types of reuse json parsing? ? ?
Reply:
The results still suffocating! How to make the data corresponding to a strip show? Why take the data front and anyType ah damn String
Reply:
It depends on the how to write http://192.168.1.195:88/service1.asmx this webservice return data definitions
Reply:
A better approach is: a good return on both sides to define the data format, preferably json format, which can be google can also be apache, and analytical tools so that you can be here when parsing apache provided by google or , very convenient.

If you give directly to parse the string, then write their own methods to deal with. . . . I can not think of other ways
Reply:
Thank you for helping, finally finally solved the problem: parsing soapObject specifically wrote a class to complete the goal, the main method:
 public static ArrayList > parseSoapObjectToList (
SoapObject so) {
ArrayList > data = new ArrayList > ();
if (so! = null) {
int size = so.getPropertyCount ();
if (size> 0) {
Map map = null;
for (int i = 0; i int tag = i% 3;
switch (tag) {
case 0: {
map = new HashMap ();
map.put ("Id", so.getProperty (i) toString ().);
}
break;
case 1: {
map.put (. "Name", so.getProperty (i) toString ());
}
break;
case 2: {
map.put (. "Status", so.getProperty (i) toString ());
data.add (map);
}
break;

default:
break;
}
}
}
}
return data;

}

Reply:
Your method is very good, I ask you how the query results are displayed in? Do with the Listview
Reply:
Landlord you and I encountered the same problem you can send a demo to me it 1322566179@qq.com good

Android application development issues Baidu map location, novice seeking Great God help look


I am graduating students, work in the company, because the development needs, I went to study under the open platform Baidu Baidu Maps Map Android SDK location positioning function, and then I wrote a map to show your current location plus locate code. Why is my program, which is indeed the position of the positioning of the Pacific, rather than my current position, ah, then God help us to see where to find the big problem, the way to help me think about how can locate the point display "longitude latitude" and If I move a distance I could see the start position to the stop position trajectory. I am a beginner, it is best to explain the point code? Thank you
ps: all v.2.4.1 Android positioning Baidu Maps latest Android SDK Sdk
adoptedCode:
AndroidMainfest.xml

package = "com.blunt.demo"
android: versionCode = "1"
android: versionName = "1.0">
android: anyDensity = "true"
android: largeScreens = "true"
android: normalScreens = "true"
android: resizeable = "true"
android: smallScreens = "true" />

android: minSdkVersion = "14"
android: targetSdkVersion = "14" />
<-! Required permission to use network functions ->








<-! SDK offline map and write cache feature requires an external memory ->




<-! Get Set information and details page directly call phone needs the following permissions ->




<- Required permission to use positioning, demo integrated Baidu positioning SDK, can be removed without the use of targeting the following 6 -!>
















android: allowBackup = "true"
android: icon = "@ drawable / ic_launcher"
android: label = "@ string / app_name"
android: theme = "@ style / AppTheme">

android: name = "com.blunt.demo.MyMapActivity"
android: configChanges = "orientation | keyboardHidden"
android: label = "@ string / app_name"
android: screenOrientation = "sensor">







android: name = "com.baidu.lbsapi.API_KEY"
android: value = "secret key" />
android: name = "com.baidu.location.f"
android: enabled = "true"
android: process = ": remote" />






Main Activity


public class MyMapActivity extends Activity

{
private static final String TAG = "TAG";

BMapManager mBMapMan = null;
MapView mMapView = null;

/ / Get site location information
private LocationClient locationClient = null;
private BDLocationListener bdLocationListener = new MyLocationListener ();

/ / Locate the current position

private MyLocationOverlay myLocationOverlay = null;
private LocationData locationData = null;

Handler mHandler = new Handler ()
{
public void handleMessage (android.os.Message msg)
{
Toast.makeText (getApplicationContext (), "msg:" + msg.what,
. Toast.LENGTH_SHORT) show ();
};
};

@ Override
public void onCreate (Bundle savedInstanceState)
{
super.onCreate (savedInstanceState);
mBMapMan = new BMapManager (getApplication ());
mBMapMan.init (null);

/ / Note: Please initialize BMapManager object before trial setContentView, otherwise it will error
setContentView (R.layout.activity_my_map);
mMapView = (MapView) findViewById (R.id.bmapsView);
mMapView.setBuiltInZoomControls (true);
/ / Set to enable the built-in zoom controls
MapController mMapController = mMapView.getController ();

locationClient = new LocationClient (getApplicationContext ());
locationClient.registerLocationListener (bdLocationListener);

LocationClientOption option = new LocationClientOption ();
option.setOpenGps (true); / / whether to open GPRS
option.setAddrType ("all") ;/ / positioning results returned contain address information
option.setCoorType ("bd09ll") ;/ / positioning results returned is Baidu latitude and longitude, the default value gcj02
option.setScanSpan (50000) ;/ / set the interval to initiate positioning request to 5000ms
option.disableCache (true) ;/ / enable caching positioning
banoption.setPoiNumber (5); / / returns the maximum number of
POIoption.setPoiDistance (1000); / / poi inquiries from
option.setPriority (LocationClientOption.NetWorkFirst);
locationClient.setLocOption (option);
locationClient.start ();
if (locationClient! = null && locationClient.isStarted ())
{
locationClient.requestLocation ();
locationClient.requestPoi ();
} Else
{
Log.d (TAG, "locClient is null or not started");
}

mMapController.setZoom (12) ;/ / set the map zoom level

myLocationOverlay = new MyLocationOverlay (mMapView);
locationData = new LocationData ();
myLocationOverlay.setData (locationData);
mMapView.getOverlays () add (myLocationOverlay);.
myLocationOverlay.enableCompass ();
mMapView.refresh ();

}




@ Override
protected void onStop ()
{
locationClient.stop ();
super.onStop ();
}

@ Override
protected void onDestroy ()
{

mMapView.destroy ();
locationClient.unRegisterLocationListener (bdLocationListener);

if (mBMapMan! = null)
{
mBMapMan.destroy ();
mBMapMan = null;
}
locationClient.stop ();
myLocationOverlay.disableCompass ();
myLocationOverlay = null;
mMapView = null;
locationClient = null;
locationData = null;
super.onDestroy ();
}

@ Override
protected void onPause ()
{

mMapView.onPause ();
if (mBMapMan! = null)
{
mBMapMan.stop ();
}
locationClient.stop ();

super.onPause ();
}

@ Override
protected void onResume ()
{

mMapView.onResume ();
if (mBMapMan! = null)
{
mBMapMan.start ();
}
locationClient.start ();
super.onResume ();
}

private class MyLocationListener implements BDLocationListener
{

@ Override
public void onReceiveLocation (BDLocation location)
{
/ / Log.v (TAG,
/ / "OnReceiveLocation ---> getLatitude --->" + String.valueOf (position.getLatitude ()))
/ /;
/ / Log.v (TAG,
/ / "OnReceiveLocation ---> getLocType --->" + String.valueOf (position.getLongitude ()))
/ /;
/ / Log.v (TAG,
/ / "OnReceiveLocation ---> getRadius --->" + String.valueOf (position.getRadius ()))
/ /;
/ / Log.v (TAG,
/ / "OnReceiveLocation ---> position --->" + String.valueOf (position.getAddrStr ()))
/ /;

locationData.latitude = location.getLatitude ();
locationData.longitude = location.getLongitude ();
locationData.accuracy = location.getRadius ();
locationData.direction = location.getDerect ();
myLocationOverlay.setData (locationData);
mMapView.refresh ();
mMapView.getController (). animateTo (
new GeoPoint ((int) (locationData.latitude * 1e6),
(Int) (locationData.longitude * 1e6)),
mHandler.obtainMessage (1));

}

@ Override
public void onReceivePoi (BDLocation location)
{
locationData.latitude = location.getLatitude ();

locationData.longitude = location.getLongitude ();

}

}
}
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Position offset is too large, then consider whether or not to engage in bad latitude and longitude
Reply:
I considered this reason, did not write bad ah

Reply:
Click to get MyLocationListener inside debug precision latitude, see if it is the correct value, whether the positioning, whether to get into the accuracy of latitude

Design problems Andrews login client, help ~ ~ ~ ~ ~ ~ ~


Using C / S structure, the back-end server using MyEclipse Servlet written in connection with the database login interface with tomcat release, front design with Eclipse Android client, how to connect client and server side of it? The client can be achieved by a successful login account password, seeking detailed advice? I am a novice, the first contact with such things, there are a lot of vacant places, hope to have expert advice!
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Your own ideas is not very clear yet.
Client and server links related to Socket Programming. If the client and server connected, and you can pass the login information (such as user name, password) in between, in the background doing verification. Is there any question it. .
Reply:
Why not have the address, port number, not have it, the machine is not localhost: ip chant changed to native
Reply:
Just getting started, then use http to achieve the transfer of data to a simple point of it
Reply:
android client uses HttpURLConnection or HttpClient

Android 4.2 Wireless display to communicate with the PC


Android 4.2 has a Wireless display technology, the sound through wireless image transfer to a TV or other tablets to support the technology.

Now the question is, is there a way to image the Tablet PC, transfer the sound to the PC computer via Wireless display technology?
To say the least, no longer limited to the transmission mode Wireless display, as long as there is a viable way to synchronize voice data tablet PC computer, are possible.
For PC computer's operating system is limited to Windows and Linux platforms.

You greatly who have any suggestions or relevant aspects of the item?
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
With socket do not you?
Reply:
cited a floor gesanri reply:
with a socket do not you?

Ah, thank you reply.
However, this involves capturing the image and sound systems, better images, sounds, then read a lot of ways, so far no one is entirely feasible, there is always this kind of problems or limitations.
Reply:
Their top.
Reply:
Zaiding, then knot stickers.

NDK breakpoint debugging JNI code in C


My environment is setting up the. Direct use NDK breakpoint debugging C code, http://tools.android.com/recent/usingthendkplugin steps refer to the official website, but after setting breakpoints, debug native run directly run over, did not enter the set breakpoint. Is this what the reason ah.
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Halo, all gdb ah
Reply:
cited a floor DrSmart reply:
Halo, all gdb ah
not gbd ah, NDK can be
Reply:
The landlord did not solve the problem, I was the problem, there is no successful next breakpoint! !
Reply:
Landlord problem solved? ?

httpclient () post a wonderful question!


 private String connServerForResult (String path, String contents) {
/ / TODO Auto-generated method stub
HttpClient client = new DefaultHttpClient ();
String json = null;

try {
/ / Destination address
HttpPost request = new HttpPost (path);
/ / Constructor string data
StringEntity entity = new StringEntity (contents);
/ / Set the type
entity.setContentType ("application / x-www-form-urlencoded");

entity.setContentEncoding (new BasicHeader (HTTP.CONTENT_ENCODING, HTTP.UTF_8));
Data
/ / Set requestrequest.setEntity (entity);
/ / Execute
HttpResponse response = client.execute (request);
HttpEntity httpentity = response.getEntity ();
/ / Result
json = EntityUtils.toString (httpentity);
System.out.println ("account" + json);
} Catch (Exception e) {
e.printStackTrace ();
}
return json;
}
};

This is the code! When tested post no problem! But the real address changed after the server can not obtain the data I post up! Can return an error message! This is what ah? (Server code is the same)
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Determine under your server address is correct, see what type of error return. Whether the server receives a request
Reply:
respones can see the code, and a code to see what is wrong, and then re-check the correctness of combining url
Reply:
Themselves! Is the problem server address!