我正在开发一个有两个活动的Android应用程序。一个是菜单屏幕,另一个是用户在做出选择后实际使用的屏幕。第二个活动在工作线程中完成所有处理。当我选择继续进行第二个活动时,它会“闪烁”活动约100毫秒。我发现一些日志看起来像他们会告诉我如果我知道他们的意思我需要修理什么。
02-29 10:52:33.850: I/ActivityManager(1255): Starting activity: Intent { cmp=com.wcf.imageShare/.ImageShareActivity }
02-29 10:52:33.920: W/InputManagerService(1255): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@45c0a198 (uid=10097 pid=24918)
02-29 10:52:33.936: W/WindowManager(1255): No window to dispatch pointer action
02-29 10:52:33.952: I/ActivityManager(1255): Displayed activity com.wcf.imageShare/.ImageShareActivity: 96 ms (total 96 ms)
02-29 10:52:34.000: W/WindowManager(1255): No window to dispatch pointer action 1
程序本身没有崩溃,它只是让我回到菜单视图并再次显示我的选择。这是我用来切换活动的代码
lstServers.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
Beacon.activeServer = position;
Intent uploadIntent = new Intent(inst,ImageShareActivity.class);
inst.startActivity(uploadIntent);
}
});
inst保存代码运行的活动的'this'变量,因为我无法通过使用'this'来引用它
以下是我要切换到的活动的onCreate:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try
{
progBar = (ProgressBar)findViewById(R.id.progressbar_Horizontal);
tv = (TextView)findViewById(R.id.prog_txt);
btnCancel = (Button)findViewById(R.id.cancel);
btnCancel.setOnClickListener(new OnClickListener()
{
public void onClick(View arg0)
{
try {
uploaderThread.interrupt();
Uploader.CancelUpload();
} catch (Exception e) {
e.printStackTrace();
}
}
});
uploaderThread.start();
}
catch(Exception e)
{
Log.d("Uploader ERROR",e.getMessage());
}
}
最后是清单文件中与这两个活动有关的部分。
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:debuggable="true">
<activity
android:name=".ImageShareActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
</activity>
<activity android:name=".ServerChoiceActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<data android:mimeType="image/*"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
有没有人有任何建议或知道我遗失的事情?
由于
Nick Long
答案 0 :(得分:1)
将此更改为:
lstServers.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
Beacon.activeServer = position;
Intent uploadIntent = new Intent(your_current_activty.this,ImageShareActivity.class);
uploadIntent.startActivity();
}
});