0
我從我的活動開始服務,然後致電finish()。問題是,在包中創建的其他類在服務的onStart上爲null,並且在onStart上創建的類是我開始新活動時的類。Android服務和包裝
如何解決這個問題?
感謝, 那鴻
下面是示例代碼:
class Bridge
{
static Bridg BridgeInstence;
public Bridge()
{
BridgeInstance = this;
}
}
class MainActivity
{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
JNIBridge b = new JNIBridge(assetManager);
startService(new Intent(this, MainService.class));
finish();
}
public class MainService extends Service
{
public int onStartCommand(Intent intent, int flags, int startId) {
//Bridge.BridgeInstance is NULL here!!!!
}
這不是真正清楚是什麼問題。一些示例代碼會有所幫助。 – jsmith 2012-03-01 14:17:04
謝謝,我添加了一些樣品 – nmnir 2012-03-03 04:57:13