Jump to content
FMAUPIN

Impossible de démarrer une activité à partir d'une autre sous Android Lollipop

Recommended Posts

Bonjour à toutes & tous,

 

je n'arrive pas à lancer une activité à partir de mon activité principale.

 

J'ai essayé de nombreuses solutions sans succès.

 

 

Voici mon Manifest.xml :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fmaupin.cogito">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_titre"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".Main2Activity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />

<activity
android:name=".SendLog"
android:theme="@style/AppTheme.NoActionBar"
android:exported="true"
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="com.fmaupin.cogito.SEND_LOG" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

</application>

</manifest>

Main2Activity est ma principale activité.

 

SendLog est l'activité à démarrer.

 

 

Extrait de la classe Main2Activity :

@[member=override]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);

// Setup handler for uncaught exceptions.
Thread.setDefaultUncaughtExceptionHandler(
new Thread.UncaughtExceptionHandler()
{
@[member=override]
public void uncaughtException (Thread thread,
Throwable e)
{
handleUncaughtException (thread, e);
}
});

...

}
}

private boolean isUIThread(){
return
Looper.getMainLooper().getThread() == Thread.currentThread();
}

private void handleUncaughtException (Thread thread,
final Throwable e)
{
if (isUIThread()) {
invokeLogActivity(e);
} else { //handle non UI thread throw uncaught exception
new Handler(Looper.getMainLooper()).post(new Runnable() {
@[member=override]
public void run() {
invokeLogActivity(e);
}
});
}
}

private void invokeLogActivity(Throwable e){
Intent intent = new Intent(getApplicationContext(), SendLog.class);

intent.setFlags(
Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.putExtra("stackTrace", e);

ActivityCompat.startActivity(Main2Activity.this, intent, null);
}

Extrait logcat :

06-16 14:48:28.894 1485-1499/system_process I/ActivityManager: START u0 {flg=0x10008000 cmp=com.fmaupin.cogito/.SendLog (has extras)} from uid 10053 on display 0**

06-16 14:48:28.902 1485-1509/system_process I/WindowManager: Screen frozen for +1s63ms due to Window{1af515b4 u0 Starting com.fmaupin.cogito}

06-16 14:48:28.905 1686-2200/android.process.media W/MediaScanner: Error opening directory '/storage/sdcard/.android_secure/', skipping: Permission denied.

06-16 14:48:28.936 1686-2200/android.process.media V/MediaScanner: pruneDeadThumbnailFiles... android.database.sqlite.SQLiteCursor@227a3d81

06-16 14:48:28.936 1686-2200/android.process.media V/MediaScanner: /pruneDeadThumbnailFiles... android.database.sqlite.SQLiteCursor@227a3d81

06-16 14:48:29.014 1485-1499/system_process V/WindowManager: addAppToken: AppWindowToken{1fae314e token=Token{8d1b449 ActivityRecord{1e73ca50 u0 com.fmaupin.cogito/.SendLog t46}}} to stack=1 task=46 at 1

06-16 14:48:29.016 2182-2190/? I/art: Debugger is no longer active
06-16 14:48:29.019 1485-1509/system_process V/WindowManager: Adding window Window{636a381 u0 Starting com.fmaupin.cogito} at 3 of 8 (after Window{1af515b4 u0 Starting com.fmaupin.cogito})

06-16 14:48:29.032 1994-1994/com.android.calendar D/AlertReceiver: onReceive: a=android.intent.action.BOOT_COMPLETED Intent { act=android.intent.action.BOOT_COMPLETED flg=0x8000010 cmp=com.android.calendar/.alerts.AlertReceiver (has extras) }

D'après ces logs, il semble que l'activité SendLog démarre... mais rien à l'écran !!!

 

 

Extrait de la classe SendLog :

public class SendLog extends AppCompatActivity {

private static final String TAG = "SendLog";

private Throwable stackTrace;

@[member=override]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_send_log);

// get stack trace of uncaught exception
stackTrace = (Throwable) getIntent().getSerializableExtra("stackTrace");

...

}
}

Une idée ?

 

Merci par avance

 

 
 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.






×
×
  • Create New...