[Xposed Framework Development] jjdcsp:
We are working with a Galaxy S3 (Android 4.1.1). We are able to get the activity from param.thisObject and change the title by getting the activity and calling setTitle(), but when we want to start a new activity, the activity doesn't start. Does anyone know how to spawn a new activity?

Our code is building off of SmileyClock in the tutorial.

Main.java

---------------------------------------------------------------------------------------------------------------------------------------------------------------

package com.example.SmileyClock;

import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;

import android.aMain.javapp.Activity;

import android.content.Intent;

import android.util.Log;

import android.view.View;

import android.widget.TextView;

import de.robv.android.xposed.IXposedHookLoadPackage;

import de.robv.android.xposed.XC_MethodHook;

import de.robv.android.xposed.XSharedPreferences;

import de.robv.android.xposed.XposedBridge;

import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;

public class Main implements IXposedHookLoadPackage {

[MENTION=439709]override[/MENTION]

public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {

// TODO Auto-generated method stub

if (!lpparam.packageName.equals("com.android.phone"))//check if the package being loaded is systemUI

return;

//All code here is only called if it is indeed SystemUI

findAndHookMethod("com.android.phone.EmergencyDialer", lpparam.classLoader, "placeCall", new XC_MethodHook() {

[MENTION=439709]override[/MENTION]

protected void afterHookedMethod(MethodHookParam param) throws Throwable {

Activity emergencyDialer = (Activity) param.thisObject;

emergencyDialer.setTitle("Title has been changed!");

Intent newIntent = new Intent(emergencyDialer, BlackScreenActivity.class);

newIntent.addFlgags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

emergencyDialer.startActivity(newIntent);

Activity emergencyDialer = (Activity) param.thisObject;

Object[] args = param.args;

View view = (View) args[0];

emergencyDialer.setTitle("" + view.getId());

Intent newIntent = new Intent(Intent.ACTION_VIEW, null, emergencyDialer, BlackScreenActivity.class);

emergencyDialer.startActivity(newIntent);

}

});

}

}

BlackScreenActivity.java

---------------------------------------------------------------------------------------------------------------------------------------------------------------

package com.example.SmileyClock;

import android.app.Activity;

import android.os.Bundle;

import android.util.Log;

import android.view.Menu;

import android.view.MenuItem;

import android.view.Window;

import android.view.WindowManager;

public class BlackScreenActivity extends Activity {

[MENTION=439709]override[/MENTION]

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_black_screen);

//Remove title bar

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

//Remove notification bar

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN);

//set content view AFTER ABOVE sequence (to avoid crash)

this.setContentView(R.layout.activity_black_screen);

try {

Thread.sleep(3000);

finish();

Log.v("Xposed", "Sleep is done");

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

Log.v("ERROR CATCH THING", e.toString());

}

}

[MENTION=439709]override[/MENTION]

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.black_screen, menu);

return true;

}

[MENTION=439709]override[/MENTION]

public boolean onOptionsItemSelected(MenuItem item) {

// Handle action bar item clicks here. The action bar will

// automatically handle clicks on the Home/Up button, so long

// as you specify a parent activity in AndroidManifest.xml.

int id = item.getItemId();

if (id == R.id.action_settings) {

return true;

}

return super.onOptionsItemSelected(item);

}

}