我有这个奇怪的问题.我正在检索twitters,它可以在模拟器和我的三星Galaxy S上运行,但它在我的Galaxy Tab 10.1上不起作用?
手机和标签上都安装了相同的应用程序.从Eclipse生成所以没有调试或任何东西.
需要不同的权限?
这是代码:
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(searchUrl);
ResponseHandler<String> responseHandler = new BasicResponseHandler();
responseBody = client.execute(get, responseHandler);
Run Code Online (Sandbox Code Playgroud)
这是显而易见的:
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Run Code Online (Sandbox Code Playgroud) java android httpurlconnection ui-thread android-4.0-ice-cream-sandwich
我使用以下代码在支持YouTube的活动(通常是浏览器)中加载YouTube视频:
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=" + videoId));
context.startActivity(i);
Run Code Online (Sandbox Code Playgroud)
我收到了此匿名跟踪跟踪,无法弄清楚这是怎么发生的。这是否意味着设备不知道需要使用什么活动来处理“ http”协议?(即没有浏览器?)
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://www.youtube.com/watch?v=xxxxxx }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
at android.app.Activity.startActivityForResult(Activity.java:3190)
at android.app.Activity.startActivity(Activity.java:3297)
at com.sprogcoder.basetube.d.c.a(Unknown Source)
at com.sprogcoder.basetube.f.b.onItemClick(Unknown Source)
at android.widget.AdapterView.performItemClick(AdapterView.java:292)
at android.widget.Gallery.onSingleTapUp(Gallery.java:960)
at android.view.GestureDetector.onTouchEvent(GestureDetector.java:568)
at android.widget.Gallery.onTouchEvent(Gallery.java:937)
at android.view.View.dispatchTouchEvent(View.java:5546)
Run Code Online (Sandbox Code Playgroud)
谢谢!
我试图在最小API为10的情况下实现CursorLoader和LoaderManager.
但是,我继续在AsyncTaskLoader.class的第63行获得IllegalArgument异常(AsyncTaskLoader.class的源代码,其中发生异常的是下面和此链接.
/* Runs on the UI thread */
@Override
protected void onPostExecute(D data) {
if (DEBUG) Log.v(TAG, this + " onPostExecute");
try {
AsyncTaskLoader.this.dispatchOnLoadComplete(this, data);
} finally {
done.countDown();
}
}
Run Code Online (Sandbox Code Playgroud)
下面是错误的堆栈:
AsyncTaskLoader$LoadTask.onPostExecute(Object) line: 63
AsyncTaskLoader$LoadTask(ModernAsyncTask).finish(Object) line: 461
ModernAsyncTask.access$500(ModernAsyncTask, Object) line: 47
ModernAsyncTask$InternalHandler.handleMessage(Message) line: 474
ModernAsyncTask$InternalHandler(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 137
ActivityThread.main(String[]) line: 4424
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 511
ZygoteInit$MethodAndArgsCaller.run() line: 784
ZygoteInit.main(String[]) line: 551
NativeStart.main(String[]) …
Run Code Online (Sandbox Code Playgroud) sqlite android illegalargumentexception android-loadermanager android-cursorloader
我使用的是CursorAdapter
和ContentProvider
,我想用CursorLoader
,所以我重新配置我的项目目标API 11,并设置分-SDK-版本7.但是它崩溃时Activity
调用子Activity
,它使用CursorLoader
.错误NoClassDefFoundError
通过IllegalStateException
.
我的问题是,即使我们有相同的配置,我们可以在以前的Android版本中使用Honeycomb API吗?
java android android-contentprovider android-loadermanager android-cursorloader
findViewById(R.id.list)没有解决?
我收到以下错误消息:无法解析R.id.list.
我正在扩展ListActivity,在布局中我有ListView android:id ="@ android:id/list"
public class Results extends ListActivity {
static final String TAG = "Results";
ListView m_lv;
List<Map<String, String>> m_dataList = null;
ListView lv;
SimpleAdapter m_adapter;
ProgressDialog m_dialog;
AsyncTask<String, String, String> bg;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listviewparent);
lv = (ListView) findViewById(R.id.list);
lv = getListView();
Run Code Online (Sandbox Code Playgroud)
下面是listviewparent.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout style="@style/TitleBar">
<ImageButton style="@style/TitleBarAction"
android:contentDescription="@string/description_home"
android:src="@drawable/title_home"
android:onClick="onClickHome" />
<ImageView style="@style/TitleBarSeparator" />
<TextView style="@style/TitleBarText" />
<ImageButton style="@style/TitleBarAction"
android:contentDescription="@string/description_about"
android:src="@drawable/title_about"
android:onClick="onClickAbout" />
<ImageButton …
Run Code Online (Sandbox Code Playgroud) 这是我的email_dialog.xml
布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TableRow
android:id="@+id/tableRow0"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TableRow>
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="@+id/txtEmailAddress5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:text="mFry@smithmicro.com"/>
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btnCancelEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="200px"
android:text="Cancel" />
<Button
android:id="@+id/btnOkEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="200px"
android:text="Email" />
</TableRow>
Run Code Online (Sandbox Code Playgroud)
这是我调用和使用它的方法:
void showEmailDialog() {
// Final prevents the error in the newest onClick callback.
final Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.email_dialog);
dialog.setTitle("Enter Email Address");
dialog.setCancelable(true);
final EditText txtEA = (EditText) findViewById(R.id.txtEmailAddress5);
final Button …
Run Code Online (Sandbox Code Playgroud) 来自Android SDK的这个页面
默认实现通过在层次结构中具有 id 的每个视图上调用 onSaveInstanceState() 并保存当前聚焦视图的 id(所有这些都由onRestoreInstanceState(Bundle) 的默认实现)。
那么有没有一种机制可以自动保存Activity状态而不保存Activity中每个元素的值呢?我对上面的说法感到困惑。
例如,活动 A 调用了活动 B。在活动 B 中,我有复选框、单选按钮等。用户选择他们的选择并单击后退按钮。我正在显示 Activity 此时,我想保存用户选择。当用户再次从活动 A 返回到 B 时,通过单击按钮,我希望看到所有选择都保留下来。我能想到的一种方法是,设置 Intent Flag 以突出 Activity。但我认为不是推荐的方法。
那么是否有一个默认实现来保存状态,根据 SDK 的上述文本?或者我可能解释错了?
我想创建一个在Java中实现它自己的一些方法的接口(但是语言不允许这样做,如下所示):
//Java-style pseudo-code
public interface Square {
//Implement a method in the interface itself
public int getSize(){//this can't be done in Java; can it be done in C++?
//inherited by every class that implements getWidth()
//and getHeight()
return getWidth()*getHeight();
}
public int getHeight();
public int getWidth();
}
//again, this is Java-style psuedocode
public class Square1 implements Square{
//getSize should return this.getWidth()*this.getHeight(), as implemented below
public int getHeight(){
//method body goes here
}
public int getWidth{
//method body goes here
} …
Run Code Online (Sandbox Code Playgroud) 当我尝试更新Android应用中的数据库行时出现错误.它似乎认为没有专栏last_update_time
,但我绝对肯定有一个专栏.我已经创建并重新创建了几次数据库并检查了我的SQL语句,这个名称肯定有一个列.
一些日志声明:
02-13 14:31:09.508: I/Database(674): sqlite returned: error code = 1, msg = no such column: last_update_time
02-13 14:31:09.508: E/Database(674): Error updating icon=http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png last_update_time=1329172268604 distance=36.571194 _id=ba1f46d735746b66658bb970e842d647ea7f92d8 vicinity=3561 El Camino Real #75,
Santa Clara name=Paris Baguette longitude=-121.994223 latitude=37.353605 types=bakery store food establishment reference=
CnRlAAAAddN_wZD9BvHL0LCzxJUgzf_QcaFUVcIyDRPf26pRyrUVJ1yVkUkke420FEhwkaNfsZedlqrhaRJJwelopAYWEPRr7mAL81vivvlntYSSqS0xUxke655C7ay4AyOpaCO1BE7XbDmQSTV7WINl8c7W0hIQ_DXJBG0pSWe3P1gaJQOSuRoURMAs2eYOIzExARulJ7B7k5EK97c using UPDATE places SET icon=?,
last_update_time=?, distance=?, _id=?, vicinity=?, name=?, longitude=?, latitude=?, types=?, reference=? WHERE _id = ba1f46d735746b66658bb970e842d647ea7f92d8
02-13 14:31:09.518: E/AndroidRuntime(674): android.database.sqlite.SQLiteException: no such column: last_update_time: , while compiling: UPDATE places SET icon=?,
last_update_time=?, distance=?, …
Run Code Online (Sandbox Code Playgroud) android ×8
java ×5
sqlite ×2
android-4.0-ice-cream-sandwich ×1
database ×1
exception ×1
interface ×1
savestate ×1
text-files ×1
ui-thread ×1