Android 2.3.6 デバイスおよびすべての 4.x 仮想デバイスで正常に動作する Android アプリを用意します。ただし、ユーザーから、4.0.4 から 4.1.1 を実行している複数のデバイスで、別のアプリに移動して再度戻らない限り、1 つのアクティビティが表示されないという報告を受けました。考えられるすべてのことを試しましたが、違いはありません。仮想デバイスでバグを再現できないため、自分でデバッグ (またはテスト) することはできません。このユーザーに何が起こるかを示すビデオ クリップを次に示します。
表示されないアクティビティの呼び出しは次のとおりです。
Intent stationList = new Intent(LoggedIn.this, StationList.class);
stationList.putExtra("stationlist", stationlist);
startActivityForResult(stationList, 1);
ステーション リスト アクティビティの内容:
public class StationList extends ListActivity {
private ListView list ;
private ArrayAdapter<String> listAdapter ;
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode==KeyEvent.KEYCODE_BACK)
{
Intent returnIntent = new Intent();
setResult(RESULT_CANCELED,returnIntent);
finish();
}
return true;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list);
// Find the ListView resource.
list = (ListView) findViewById( android.R.id.list );
// Create and populate a List of stations.
String stationlist = getIntent().getExtras().getString("stationlist");
final String[] stationListArray = stationlist.split("\n");
ArrayList<String> stationList = new ArrayList<String>();
stationList.addAll( Arrays.asList(stationListArray) );
// Create ArrayAdapter using the station list.
listAdapter = new ArrayAdapter<String>(StationList.this, R.layout.simplerow, stationList);
// Set the ArrayAdapter as the ListView's adapter.
list.setAdapter( listAdapter );
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> list, View view,
int position, long id) {
// Get the cursor, positioned to the corresponding row in the result set
String channel = "echo -n 'notempty' > ~/.config/pianobar/stationcreate && echo '" + position + "' >> ~/.config/pianobar/ctl";
Toast.makeText(getApplicationContext(),
"Starting station " + stationListArray[position] +", please wait", Toast.LENGTH_LONG).show();
Intent returnIntent = new Intent();
returnIntent.putExtra("channel",channel);
setResult(RESULT_OK,returnIntent);
finish();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_station_list, menu);
return true;
}
}
リスト.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".StationList" >
<ListView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/list">
</ListView>
<TextView
android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Loading station data..." />
</LinearLayout>
Simplerow.xml:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rowTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:textSize="16sp" >
</TextView>