Photochooser task not working after phone was synced with PC? - Windows Phone 7 Software Development

hello guys and girls,
I have a very peculiar problem with my application (two actually, working together to make a bigger problem)
I have a resume tile, which allows the users to resume working on the picture they were working after navigating away from the game.
Now, the users can choose pictures in their media lib to use in the game.
However, after i sync my phone to laptop, unplug it, then try to use the resume tile, it simply brings me to main page and does not continue doing the resume as it should do. This only happens with pictures from photochooser task: the ones integrated in the app work fine.
The photochooser task also refuses to work properly until i start the app "the usual way" and not from the resume tile. It basically goes back to the MainPage no matter what.
So, what's with all this? I think it has something to do with the syncing messing up isolated storage and phone storage.
here's some code:
MainPage:
Basically, I'm using some messages to know from where i navigated to the MainPage. The "resumeTile" message is obviously coming from the resume tile, whereas "FromPlay" means the player just left the play page.
App.IsFirstLoaded is used to known that it loaded already and should ignore the "ResumeTile" message and continue with the resume, but not to repeat the same feat in case the user navigates from any page in the game.
Code:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
string msesage = null;
try
{
NavigationContext.QueryString.TryGetValue("message", out msesage);
if (msesage == "resumeTile")
{
App.isFirstLoaded = true;
}
if (msesage == "FromPlay")
{
NavigationService.RemoveBackEntry();
}
if (App.isFirstLoaded == true)
{
resume_SubmitResume();
App.isFirstLoaded = false;
msesage = null;
}
else
{
//NavigationService.RemoveBackEntry();
base.OnNavigatedTo(e);
if (msg == "openPlay")
{
string msggs = msg;
msg = null;
if (portrait)
{
NavigationService.Navigate(new Uri("/PlayPage.xaml?msg=" + msggs, UriKind.Relative));
}
else
{
NavigationService.Navigate(new Uri("/PlayPageLandscape.xaml?msg=" + msggs, UriKind.Relative));
}
}
}
}
catch (NullReferenceException)
{
}
}
and here is the photochooser task completed event handler
Code:
void photochoser_Completed(object sender, PhotoResult e)
{
string path = "mhgcjtcthgg.jpg";
if (e.TaskResult == TaskResult.OK)
{
using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite, IsolatedStorageFile.GetUserStoreForApplication()))
{
if (e.Error == null)
{
if (App.AutoSave == true)
{
MediaLibrary ml = new MediaLibrary();
ml.SavePicture("CountlessPuzzles" + DateTime.Now.ToShortTimeString(), e.ChosenPhoto);
}
BitmapImage bi = new BitmapImage();
bi.SetSource(e.ChosenPhoto);
WriteableBitmap wb = new WriteableBitmap(bi);
if (wb.PixelHeight <= wb.PixelWidth)
{
Extensions.SaveJpeg(wb, fs, DHeigh, DWidth, 0, 100);
//NavigationService.Navigate(new Uri("/PlayPageLandscape.xaml?msg=" + msg, UriKind.Relative));
}
else
{
Extensions.SaveJpeg(wb, fs, DWidth, DHeigh, 0, 100);
//NavigationService.Navigate(new Uri("PlayPage.xaml?msg=" + msg, UriKind.Relative));
portrait = true;
}
}
}
}
msg = "openPlay";
}
else
{
isDataSavedInIsolatedStorage = false;
}
// e.ChosenPhoto.Close();
}
So, any ideas?

mcosmin222 said:
hello guys and girls,
I have a very peculiar problem with my application (two actually, working together to make a bigger problem)
I have a resume tile, which allows the users to resume working on the picture they were working after navigating away from the game.
Now, the users can choose pictures in their media lib to use in the game.
However, after i sync my phone to laptop, unplug it, then try to use the resume tile, it simply brings me to main page and does not continue doing the resume as it should do. This only happens with pictures from photochooser task: the ones integrated in the app work fine.
The photochooser task also refuses to work properly until i start the app "the usual way" and not from the resume tile. It basically goes back to the MainPage no matter what.
So, what's with all this? I think it has something to do with the syncing messing up isolated storage and phone storage.
here's some code:
MainPage:
Basically, I'm using some messages to know from where i navigated to the MainPage. The "resumeTile" message is obviously coming from the resume tile, whereas "FromPlay" means the player just left the play page.
App.IsFirstLoaded is used to known that it loaded already and should ignore the "ResumeTile" message and continue with the resume, but not to repeat the same feat in case the user navigates from any page in the game.
Code:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
string msesage = null;
try
{
NavigationContext.QueryString.TryGetValue("message", out msesage);
if (msesage == "resumeTile")
{
App.isFirstLoaded = true;
}
if (msesage == "FromPlay")
{
NavigationService.RemoveBackEntry();
}
if (App.isFirstLoaded == true)
{
resume_SubmitResume();
App.isFirstLoaded = false;
msesage = null;
}
else
{
//NavigationService.RemoveBackEntry();
base.OnNavigatedTo(e);
if (msg == "openPlay")
{
string msggs = msg;
msg = null;
if (portrait)
{
NavigationService.Navigate(new Uri("/PlayPage.xaml?msg=" + msggs, UriKind.Relative));
}
else
{
NavigationService.Navigate(new Uri("/PlayPageLandscape.xaml?msg=" + msggs, UriKind.Relative));
}
}
}
}
catch (NullReferenceException)
{
}
}
and here is the photochooser task completed event handler
Code:
void photochoser_Completed(object sender, PhotoResult e)
{
string path = "mhgcjtcthgg.jpg";
if (e.TaskResult == TaskResult.OK)
{
using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite, IsolatedStorageFile.GetUserStoreForApplication()))
{
if (e.Error == null)
{
if (App.AutoSave == true)
{
MediaLibrary ml = new MediaLibrary();
ml.SavePicture("CountlessPuzzles" + DateTime.Now.ToShortTimeString(), e.ChosenPhoto);
}
BitmapImage bi = new BitmapImage();
bi.SetSource(e.ChosenPhoto);
WriteableBitmap wb = new WriteableBitmap(bi);
if (wb.PixelHeight <= wb.PixelWidth)
{
Extensions.SaveJpeg(wb, fs, DHeigh, DWidth, 0, 100);
//NavigationService.Navigate(new Uri("/PlayPageLandscape.xaml?msg=" + msg, UriKind.Relative));
}
else
{
Extensions.SaveJpeg(wb, fs, DWidth, DHeigh, 0, 100);
//NavigationService.Navigate(new Uri("PlayPage.xaml?msg=" + msg, UriKind.Relative));
portrait = true;
}
}
}
}
msg = "openPlay";
}
else
{
isDataSavedInIsolatedStorage = false;
}
// e.ChosenPhoto.Close();
}
So, any ideas?
Click to expand...
Click to collapse
Photochooser does not work when the phone is syncing via zune, maybe once the app is running and you try to sync, PhotoChooser crashes or something.
http://www.codeproject.com/Articles/342149/Using-WPConnect-instead-of-Zune-for-Windows-Phone

I figured that when synced, the photochooser instantiated inside the app is turned off or something, and stays so until the constructor is called again, which would happen if the app is re-launched.
Kinda peculiar though...

Related

DirectShow: Video-Preview and taking photo (with working code)

Questions
As mentioned in the text below the TakePicture() method is not working properly on the HTC HD 2 device. It would be nice if someone could look at the code below and tell me if it is right or wrong what I'm doing.
Introduction
I recently asked a question on another forum about displaying a video preview and taking camera image with DirectShow. The tricky thing about the topic is, that it's very hard to find good examples and the documentation and the framework itself is very hard to understand for someone who is new to windows programming and C++ in general.
Nevertheless I managed to create a class that implements most of this features and probably works with most mobile devices. Probably because as far as I know the DirectShow implementation depends a lot on the device itself. I could only test it with the HTC HD and HTC HD2, which are known as quite incompatible.
HTC HD
- Working: Video preview, writing photo to file
- Not working: Set video resolution (CRASH), set photo resolution (LOW quality)
HTC HD 2
- Working: Set video resolution, set photo resolution
- Problematic: Video Preview rotated
- Not working: Writing photo to file
To make it easier for others by providing a working example, I decided to share everything I have got so far below. I removed all of the error handling for the sake of simplicity. As far as documentation goes, I can recommend you to read the MSDN documentation about the topic. After that the code below is pretty straight forward.
Code:
void Camera::Init()
{
CreateComObjects();
_captureGraphBuilder->SetFiltergraph(_filterGraph);
InitializeVideoFilter();
InitializeStillImageFilter();
}
Dipslay a video preview (working with any tested handheld):
Code:
void Camera::DisplayVideoPreview(HWND windowHandle)
{
IVideoWindow *_vidWin;
_filterGraph->QueryInterface(IID_IMediaControl,(void **) &_mediaControl);
_filterGraph->QueryInterface(IID_IVideoWindow, (void **) &_vidWin);
_videoCaptureFilter->QueryInterface(IID_IAMVideoControl,
(void**) &_videoControl);
_captureGraphBuilder->RenderStream(&PIN_CATEGORY_PREVIEW,
&MEDIATYPE_Video, _videoCaptureFilter, NULL, NULL);
CRect rect;
long width, height;
GetClientRect(windowHandle, &rect);
_vidWin->put_Owner((OAHWND)windowHandle);
_vidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
_vidWin->get_Width(&width);
_vidWin->get_Height(&height);
height = rect.Height();
_vidWin->put_Height(height);
_vidWin->put_Width(rect.Width());
_vidWin->SetWindowPosition(0,0, rect.Width(), height);
_mediaControl->Run();
}
HTC HD2: If set SetPhotoResolution() is called FindPin will return E_FAIL. If not, it will create a file full of null bytes. HTC HD: Works
void Camera::TakePicture(WCHAR *fileName)
{
CComPtr<IFileSinkFilter> fileSink;
CComPtr<IPin> stillPin;
CComPtr<IUnknown> unknownCaptureFilter;
CComPtr<IAMVideoControl> videoControl;
_imageSinkFilter.QueryInterface(&fileSink);
fileSink->SetFileName(fileName, NULL);
_videoCaptureFilter.QueryInterface(&unknownCaptureFilter);
_captureGraphBuilder->FindPin(unknownCaptureFilter, PINDIR_OUTPUT,
&PIN_CATEGORY_STILL, &MEDIATYPE_Video, FALSE, 0, &stillPin);
_videoCaptureFilter.QueryInterface(&videoControl);
videoControl->SetMode(stillPin, VideoControlFlag_Trigger);
}
Set resolution: Works great on HTC HD2. HTC HD won't allow SetVideoResolution() and only offers one low resolution photo resolution:
Code:
void Camera::SetVideoResolution(int width, int height)
{
SetResolution(true, width, height);
}
void Camera::SetPhotoResolution(int width, int height)
{
SetResolution(false, width, height);
}
void Camera::SetResolution(bool video, int width, int height)
{
IAMStreamConfig *config;
config = NULL;
if (video)
{
_captureGraphBuilder->FindInterface(&PIN_CATEGORY_PREVIEW,
&MEDIATYPE_Video, _videoCaptureFilter, IID_IAMStreamConfig,
(void**) &config);
}
else
{
_captureGraphBuilder->FindInterface(&PIN_CATEGORY_STILL,
&MEDIATYPE_Video, _videoCaptureFilter, IID_IAMStreamConfig,
(void**) &config);
}
int resolutions, size;
VIDEO_STREAM_CONFIG_CAPS caps;
config->GetNumberOfCapabilities(&resolutions, &size);
for (int i = 0; i < resolutions; i++)
{
AM_MEDIA_TYPE *mediaType;
if (config->GetStreamCaps(i, &mediaType,
reinterpret_cast<BYTE*>(&caps)) == S_OK )
{
int maxWidth = caps.MaxOutputSize.cx;
int maxHeigth = caps.MaxOutputSize.cy;
if(maxWidth == width && maxHeigth == height)
{
VIDEOINFOHEADER *info =
reinterpret_cast<VIDEOINFOHEADER*>(mediaType->pbFormat);
info->bmiHeader.biWidth = maxWidth;
info->bmiHeader.biHeight = maxHeigth;
info->bmiHeader.biSizeImage = DIBSIZE(info->bmiHeader);
config->SetFormat(mediaType);
DeleteMediaType(mediaType);
break;
}
DeleteMediaType(mediaType);
}
}
}
Other methods used to build the filter graph and create the COM objects:
v
Code:
oid Camera::CreateComObjects()
{
CoInitialize(NULL);
CoCreateInstance(CLSID_CaptureGraphBuilder, NULL, CLSCTX_INPROC_SERVER,
IID_ICaptureGraphBuilder2, (void **) &_captureGraphBuilder);
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **) &_filterGraph);
CoCreateInstance(CLSID_VideoCapture, NULL, CLSCTX_INPROC,
IID_IBaseFilter, (void**) &_videoCaptureFilter);
CoCreateInstance(CLSID_IMGSinkFilter, NULL, CLSCTX_INPROC,
IID_IBaseFilter, (void**) &_imageSinkFilter);
}
void Camera::InitializeVideoFilter()
{
_videoCaptureFilter->QueryInterface(&_propertyBag);
wchar_t deviceName[MAX_PATH] = L"\0";
GetDeviceName(deviceName);
CComVariant comName = deviceName;
CPropertyBag propertyBag;
propertyBag.Write(L"VCapName", &comName);
_propertyBag->Load(&propertyBag, NULL);
_filterGraph->AddFilter(_videoCaptureFilter,
L"Video Capture Filter Source");
}
void Camera::InitializeStillImageFilter()
{
_filterGraph->AddFilter(_imageSinkFilter, L"Still image filter");
_captureGraphBuilder->RenderStream(&PIN_CATEGORY_STILL,
&MEDIATYPE_Video, _videoCaptureFilter, NULL, _imageSinkFilter);
}
void Camera::GetDeviceName(WCHAR *deviceName)
{
HRESULT hr = S_OK;
HANDLE handle = NULL;
DEVMGR_DEVICE_INFORMATION di;
GUID guidCamera = { 0xCB998A05, 0x122C, 0x4166, 0x84, 0x6A, 0x93, 0x3E,
0x4D, 0x7E, 0x3C, 0x86 };
di.dwSize = sizeof(di);
handle = FindFirstDevice(DeviceSearchByGuid, &guidCamera, &di);
StringCchCopy(deviceName, MAX_PATH, di.szLegacyName);
}
Full header file:
Code:
#ifndef __CAMERA_H__
#define __CAMERA_H__
class Camera
{
public:
void Init();
void DisplayVideoPreview(HWND windowHandle);
void TakePicture(WCHAR *fileName);
void SetVideoResolution(int width, int height);
void SetPhotoResolution(int width, int height);
private:
CComPtr<ICaptureGraphBuilder2> _captureGraphBuilder;
CComPtr<IGraphBuilder> _filterGraph;
CComPtr<IBaseFilter> _videoCaptureFilter;
CComPtr<IPersistPropertyBag> _propertyBag;
CComPtr<IMediaControl> _mediaControl;
CComPtr<IAMVideoControl> _videoControl;
CComPtr<IBaseFilter> _imageSinkFilter;
void GetDeviceName(WCHAR *deviceName);
void InitializeVideoFilter();
void InitializeStillImageFilter();
void CreateComObjects();
void SetResolution(bool video, int width, int height);
};
#endif
Hey, in the FindInterface for the you're not checking the return code, which has to be S_OK; if not, the config is NULL and using config-> will cause your crash. If FindInterface for PIN_CATEGORY_PREVIEW is failing, try FindInterface for PIN_CATEGORY_CAPTURE.

C# Battery State

Hi Everyone,
I'm making a windows mobile app in C# to help those affected by alzheimers disease and other dimentia related conditions
One function of the app is sending SMS text messages and so I'd really like to include the battery charge percentage in each text, but I can't find how to do so!
How can I put this in my program?
Thanks!
James
Use PowerBatteryStrength of Status.SystemProperty!
I know it's something to do with
Code:
Microsoft.WindowsMobile.Status.SystemState.PowerBatteryStrength.ToString();
but beyond that I'm lost! How do I put it in to my code so that I just get the string "Battery level: 42%" for example?
Signal strenght and battery level example
Hi,
Here is a simple example on how you can use the SystemState and SystemProperties.
Hope this will help you.
Code:
using System;
using System.Windows.Forms;
using Microsoft.WindowsMobile.Status;
namespace SignalAndBatteryLevel
{
public partial class BatteryAndSignalLevel : Form
{
private readonly SystemState _signalStrenght =
new SystemState(SystemProperty.PhoneSignalStrength);
private readonly SystemState _batteryLevel =
new SystemState(SystemProperty.PowerBatteryStrength);
private readonly SystemState _batteryState =
new SystemState(SystemProperty.PowerBatteryState);
public BatteryAndSignalLevel()
{
InitializeComponent();
SetSignalStrenght();
SetBatteryLevel();
_signalStrenght.Changed +=
SignalStrenghtChanged;
_batteryLevel.Changed += BatteryLevelChanged;
_batteryState.Changed += BatteryLevelChanged;
}
private void SignalStrenghtChanged(object sender,
EventArgs e)
{
SetSignalStrenght();
}
public void SetSignalStrenght()
{
_lblSignalStrenght.Text =
SystemState.PhoneSignalStrength.ToString();
}
private void BatteryLevelChanged(object sender,
EventArgs e)
{
SetBatteryLevel();
}
private void SetBatteryLevel()
{
_lblBatteryLevel.Text = GetBatteryLevel();
}
private string GetBatteryLevel()
{
string batteryLevel = "Unknown";
if (SystemState.PowerBatteryState ==
BatteryState.Charging)
{
return "Charging";
}
switch (SystemState.PowerBatteryStrength)
{
case BatteryLevel.VeryLow:
batteryLevel = "Very lowt";
break;
case BatteryLevel.Low:
batteryLevel = "Low";
break;
case BatteryLevel.Medium:
batteryLevel = "Medium";
break;
case BatteryLevel.High:
batteryLevel = "High";
break;
case BatteryLevel.VeryHigh:
batteryLevel = "Very High";
break;
}
return batteryLevel;
}
}
}
Hi PerOla,
This is really a good solution and working fine for me. Its really help me out in one of my project.
Thank you very much....
Vimal Panchal

[App] QuickSnap - Makes up for no hardware camera button

Very simple application that makes up (slightly) for not having a dedicated camera button.
Install the app, put a shortcut to it on your homepage. Shortcut will open (as quickly as possible) a preview window. Tapping anywhere on the screen will take a photo. Back button to exit.
QuickSnapNoAutofocus.apk - Takes pictures instantly, but you need a steady hand or your picture will be blurred!
QuickSnapAutoFocus.apk - Takes pictures using autofocus, so there is a delay while it focuses, but the pictures can't be blurred.
Saves the images to internal sd card as $DT.jpg on a seperate thread. Multiple taps on the screen to take lots of pictures quickly. (Supports multitouch! )
Source is in the next post - if anybody knows how to override the home or power button, give a shout!
Code:
package com.rc.QuickSnap;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import android.app.Activity;
import android.hardware.Camera;
import android.hardware.Camera.AutoFocusCallback;
import android.hardware.Camera.PictureCallback;
import android.hardware.Camera.ShutterCallback;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceHolder.Callback;
import android.view.SurfaceView;
public class QuickSnap extends Activity {
Camera cam;
ExecutorService executorService;
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
protected void onPause() {
super.onPause();
try {
cam.stopPreview();
} catch (Exception ex) {
ex.printStackTrace();
}
try {
cam.release();
} catch (Exception ex) {
ex.printStackTrace();
}
try {
executorService.shutdown();
} catch (Exception ex) {
ex.printStackTrace();
}
}
@Override
protected void onResume() {
super.onResume();
executorService = Executors.newSingleThreadExecutor();
try {
SurfaceView surface = (SurfaceView) findViewById(R.id.surface);
SurfaceHolder sh = surface.getHolder();
sh.setKeepScreenOn(true);
sh.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
sh.addCallback(new Callback() {
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
Log.i("QuickSnap", "surfaceDestroyed");
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
Log.i("QuickSnap", "surfaceCreated");
try {
cam = Camera.open();
cam.setPreviewDisplay(holder);
cam.startPreview();
} catch (Exception ex) {
ex.printStackTrace();
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
Log.i("QuickSnap", "surfaceChanged");
try {
cam.setPreviewDisplay(holder);
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
Log.i("QuickSnap", "TouchEvent");
cam.autoFocus(new AutoFocusCallback() {
@Override
public void onAutoFocus(boolean success, Camera camera) {
cam.takePicture(new ShutterCallback() {
@Override
public void onShutter() {
Log.i("QuickSnap", "Shutter");
}
}, null, new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
Log.i("QuickSnap", "JPEG");
final byte[] finaldata = data;
executorService.submit(new Runnable() {
@Override
public void run() {
try {
FileOutputStream fileOutputStream = new FileOutputStream("/sdcard/" + sdf.format(new Date()) + ".jpg");
fileOutputStream.write(finaldata);
fileOutputStream.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
camera.startPreview();
}
});
}
});
}
return true;
}
}
thx a lot !!
Looks great, gotta try. Thanks!
Has anyone got a mod that takes control of the Vol+ key for use with a camera?

Closing gps in gps event handler - endless loop

In my application when I get position latitude and longitude from GPS, I am downloading bing map to a picture box. I've been trying now to protect my application in case there is no internet connection. I've done that in the GetMap function and it works fine. After that I want to close gps - the problem is that I'm trying to do that in gps event handler - it is so because I update the picture box constantly:
Code:
void UpdateData(object sender, System.EventArgs args)
{
menuGPS.Text = "Enable GPS";
menuZoom.Enabled = false;
menuView.Enabled = false;
}
void gps_LocationChanged(object sender, Microsoft.WindowsMobile.Samples.Location.LocationChangedEventArgs args)
{
if (args.Position.LatitudeValid && args.Position.LongitudeValid)
{
if (isCameraEnabled == false)
{
try
{
pbMap.Invoke((UpdateMap)delegate()
{
pbMap.Image = bingMap.GetMap(args.Position.Latitude,
args.Position.Longitude,
zoom,
mapStyle);
});
if (pbMap.Image == null)
{
Invoke(updateDataHandler);
gpsData.gps.LocationChanged -= gps_LocationChanged;
gpsData.closeGPS();
}
}
catch (ArgumentException ex)
{
MessageBox.Show("An error has occured:" + ex.Message , "Error");
}
}
else
{
}
}
}
So after the gpsData.gps.LocationChanged -= gps_LocationChanged; and gpsData.closeGPS(); are being called in the event handler the gps gets stuck in the WaitForGpsEvents() method in GPS.cs in the while loop because bool lisening value is not changed to false.
If I put gpsData.gps.LocationChanged -= gps_LocationChanged; and gpsData.closeGPS(); to the void UpdateData(object sender, System.EventArgs args) then it stops in the Close() method on the lock condition:
// block until our event thread is finished before
// we close our native event handles
lock (this)
How can I close the GPS?

Hooking a protected List in an Inner Class with an odd set of Parameters

So, I'm getting fairly good at hooking and modifying classes, but this one is so unique, I'm not quite sure how to approach hooking it to do what I want. Code for the method/class I want to attack:
Code:
private class CreateLaunchPointListTask
extends AsyncTask<Void, Void, List<LaunchPoint>>
{
private CreateLaunchPointListTask() {}
protected List<LaunchPoint> doInBackground(Void... paramVarArgs)
{
paramVarArgs = mContext.getString(2131558445);
Object localObject = new Intent("android.intent.action.MAIN");
((Intent)localObject).addCategory(paramVarArgs);
paramVarArgs = new LinkedList();
PackageManager localPackageManager = mContext.getPackageManager();
localObject = localPackageManager.queryIntentActivities((Intent)localObject, 129);
int j = ((List)localObject).size();
int i = 0;
while (i < j)
{
ResolveInfo localResolveInfo = (ResolveInfo)((List)localObject).get(i);
if (activityInfo != null) {
paramVarArgs.add(new LaunchPoint(mContext, localPackageManager, localResolveInfo));
}
i += 1;
}
return paramVarArgs;
}
public void onPostExecute(List<LaunchPoint> arg1)
{
synchronized (mLock)
{
mAllLaunchPoints.clear();
mAllLaunchPoints.addAll(???);
synchronized (mCachedActions)
{
LaunchPointListGenerator.access$502(LaunchPointListGenerator.this, true);
if (!mCachedActions.isEmpty()) {
((LaunchPointListGenerator.CachedAction)mCachedActions.remove()).apply();
}
}
}
LaunchPointListGenerator.access$602(LaunchPointListGenerator.this, true);
Iterator localIterator = mListeners.iterator();
while (localIterator.hasNext()) {
((LaunchPointListGenerator.Listener)localIterator.next()).onLaunchPointListGeneratorReady();
}
}
}
So, while this is a big chunk of code, everything I want to do is really in the first few lines:
Code:
paramVarArgs = mContext.getString(2131558445);
Object localObject = new Intent("android.intent.action.MAIN");
((Intent)localObject).addCategory(paramVarArgs);
So, string 2131558445 is a specific intent. What I would like to do is add *another* category after 2131558445 is added to localObject.
That would be the simplest implementation.
A more advanced implementation would be to actually and return a second LinkedList, paramVarArgs2, that only matches up to the second intent category that we're inserting.
Any help would be greatly appreciated.

Categories

Resources