[q]Making Xposed module(nullpointer" - Java for Android App Development

I am trying to implement recents clear button using xposed framework.
I am getting nullpointer exception at com.android.systemui.recent.recentverticalscrollview.getchildcontentview
Code:
mRecentsClearButton = (ImageView) view.findViewById(res.getIdentifier("clear_all_button", "id", PACKAGE_NAME));
mRecentsClearButton.setClickable(true);
mRecentsClearButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ViewGroup mRecentsContainer = (ViewGroup) XposedHelpers.getObjectField(
param.thisObject, "mRecentsContainer");
// passing null parameter in this case is our action flag to remove all views
mRecentsContainer.removeAllViewsInLayout();
}
});
Sent from my GT-S5570 using XDA Premium 4 mobile app

arpitkh96 said:
I am trying to implement recents clear button using xposed framework.
I am getting nullpointer exception at com.android.systemui.recent.recentverticalscrollview.getchildcontentview
Code:
mRecentsClearButton = (ImageView) view.findViewById(res.getIdentifier("clear_all_button", "id", PACKAGE_NAME));
mRecentsClearButton.setClickable(true);
mRecentsClearButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ViewGroup mRecentsContainer = (ViewGroup) XposedHelpers.getObjectField(
param.thisObject, "mRecentsContainer");
// passing null parameter in this case is our action flag to remove all views
mRecentsContainer.removeAllViewsInLayout();
}
});
Sent from my GT-S5570 using XDA Premium 4 mobile app
Click to expand...
Click to collapse
please post the exact line that gives NPE !
make sure you get the field names right Xposed Modules can be a pain to debug !!!
Sent from my GT-S5302 using Tapatalk 2

Here is the full code.please dont read comments they are not related to code.i am trying to make this for ics 4.04.NPE comes when mRecentsClearButton is pressed.the 3 imageviews are already present in systemui.apk of the particular rom for which i am making this module.
The line mRecentsContainor.removeAllViewInLayout causes npe.
This code is inspired from gravitybox module(for jb) source code.this module had line
mRecentsContainor.removeViewInLayout(null);
Which also doesnt works.
Code:
package com.mycompany.myapp;
import android.content.res.*;
import android.view.*;
import android.widget.*;
import de.robv.android.xposed.*;
import de.robv.android.xposed.callbacks.XC_LoadPackage.*;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
public class main implements IXposedHookLoadPackage {
public static final String CLASS_RECENT_PANEL_VIEW = "com.android.systemui.recent.RecentsPanelView";
private static ImageView mRecentsClearButton;
private static ImageView mgoogle;
private static ImageView mtasker;
//private static Field fieldAnimateScreenLights;
public static final String PACKAGE_NAME = "com.android.systemui";
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
if (!lpparam.packageName.equals(PACKAGE_NAME))
return;
findAndHookMethod( CLASS_RECENT_PANEL_VIEW , lpparam.classLoader, "onFinishInflate", new XC_MethodHook() {
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
View view = (View) param.thisObject;
Resources res = view.getResources();
// GM2 already has this image view so remove it if exists
// create and inject new ImageView and set onClick listener to handle action
mRecentsClearButton = (ImageView) view.findViewById(res.getIdentifier("clear_all_button", "id", PACKAGE_NAME));
mRecentsClearButton.setClickable(true);
mRecentsClearButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ViewGroup mRecentsContainer = (ViewGroup) XposedHelpers.getObjectField(
param.thisObject, "mRecentsContainer");
// passing null parameter in this case is our action flag to remove all views
mRecentsContainer.removeAllViewsInLayout();
}
});
mgoogle= (ImageView) view.findViewById(res.getIdentifier("mgoogle", "id", PACKAGE_NAME));
mgoogle.setClickable(true);
mgoogle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
mtasker= (ImageView) view.findViewById(res.getIdentifier("mtasker", "id", PACKAGE_NAME));
mtasker.setClickable(true);
mtasker.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
});
}
}
Mtasker and mgoogle's onclick listener are empty because they are wip
Sent from my GT-S5570 using XDA Premium 4 mobile app

Log.sorry cant provide better one
Sent from my GT-S5570 using XDA Premium 4 mobile app

@arpitkh96
removeAllViews()
try calling above method on mRecent.....
this should work!
Sent from my GT-S5302 using Tapatalk 2

sak-venom1997 said:
@arpitkh96
removeAllViews()
try calling above method on mRecent.....
this should work!
Sent from my GT-S5302 using Tapatalk 2
Click to expand...
Click to collapse
Same error.
Problem is something else
Sent from my GT-S5570 using XDA Premium 4 mobile app

arpitkh96 said:
Same error.
Problem is something else
Sent from my GT-S5570 using XDA Premium 4 mobile app
Click to expand...
Click to collapse
try checking for mRecen.... != null
Sent from my GT-S5302 using Tapatalk 2

Do you mean
if(mRecentContainor!=null){mRecentsContainor.removeallView()}
Sent from my GT-S5570 using XDA Premium 4 mobile app

arpitkh96 said:
Do you mean
if(mRecentContainor!=null){mRecentsContainor.removeallView()}
Sent from my GT-S5570 using XDA Premium 4 mobile app
Click to expand...
Click to collapse
yes just to ensure the feild isnt null though i think its not !
Sent from my GT-S5302 using Tapatalk 2

sak-venom1997 said:
yes just to ensure the feild isnt null though i think its not !
Sent from my GT-S5302 using Tapatalk 2
Click to expand...
Click to collapse
Didn't work
Sent from my GT-S5570 using XDA Premium 4 mobile app

Related

[How-To][Code] AirView Samsung Galaxy S4

I didn't find a Thread with a guide for use the AirView in SGS4 so I did it.
In AndroidManifest.xml
Code:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
[B] <meta-data android:name="com.sec.android.airview.enable" android:value="true" />
<intent-filter>
<action android:name="com.sec.android.airview.HOVER" />
</intent-filter>[/B]
<activity
android:name="edu.uanl.secondapp.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
[B]<intent-filter>
<action android:name="com.sec.android.airview.HOVER" />
</intent-filter>[/B]
</activity>
</application>
You can use It this way:
Code:
View rootView = inflater.inflate(R.layout.fragment_main_dummy, container, false);
TextView dummyTextView = (TextView) rootView.findViewById(R.id.section_label);
dummyTextView.setText("Something Here");
[B] dummyTextView.setOnHoverListener(new View.OnHoverListener()[/B] {
[user=439709]@override[/user]
public boolean onHover(View view, MotionEvent motionEvent) {
switch(motionEvent.getAction()){
case 9: // Enter Hovered
case 10: // Leave Hovered
view.setBackgroundColor(Color.TRANSPARENT);
view.setScaleX((float)1.0);
view.setScaleY((float)1.0);
break;
case 7: // On Hover
view.setBackgroundColor(Color.RED);
view.setScaleX((float)2.0);
view.setScaleY((float)2.0);
break;
}
Log.wtf("Something", "I'm Being Hovered" + motionEvent.getAction());
return false;
}
});
dummyTextView.setHovered(true);
If this thread is repeated, or this is not the place to post it, my apologies I'm a semi-noob on this.
Hope this can help you.
Delete this thread if is innapropiate or something
A link to download Samsung Airview SDK and setting up samsungs cust. emulator will be handy
After all not all have an S4
Sent from my GT-S5302 using Tapatalk 2
Cool thread.
Thanks. :good:
Is that that fancy "I dont have to touch my screen" stuff? lol.
Cool how to. thanks!
http://developer.samsung.com/home.do
samsung developer site.
sak-venom1997 said:
A link to download Samsung Airview SDK and setting up samsungs cust. emulator will be handy
After all not all have an S4
Sent from my GT-S5302 using Tapatalk 2
Click to expand...
Click to collapse
sadly we don't have one sdk for this...
yet...
out of ideas said:
Is that that fancy "I dont have to touch my screen" stuff? lol.
Cool how to. thanks!
http://developer.samsung.com/home.do
samsung developer site.
Click to expand...
Click to collapse
that one itself.
Sent from my GT-I9505 using xda premium
furbyx92 said:
sadly we don't have one sdk for this...
yet...
that one itself.
Sent from my GT-I9505 using xda premium
Click to expand...
Click to collapse
No SDK yet what do these people want to do ?
No SDK for Ir Blaster to
Why the heck do they add so cool features when they dont' want developers to play with it
No apps using this feature will mean they're as good as one
they should learn from Google they never delay there SDK s
sak-venom1997 said:
No SDK yet what do these people want to do ?
No SDK for Ir Blaster to
Why the heck do they add so cool features when they dont' want developers to play with it
No apps using this feature will mean they're as good as one
they should learn from Google they never delay there SDK s
Click to expand...
Click to collapse
and this feature is the easy one.
Sent from my GT-I9505 using xda premium
furbyx92 said:
and this feature is the easy one.
Sent from my GT-I9505 using xda premium
Click to expand...
Click to collapse
You cant say the same for ir blaster
Sent from my GT-S5302 using Tapatalk 2
Yeah, I know... but I keep trying.
Thanks, nice example to kickstart a Samsung Smart App Challenge project.

Translucent/Transparent app

Hey! I am currently doing an app that will be half transparent so you can see what's behind it and interact with the apps behind my window. I searched the web and found some cool stuff but nothing that made me able to interact with apps behind, only half transparent!
Please help!
Sent from my GT-N7105 using xda premium
addemod said:
Hey! I am currently doing an app that will be half transparent so you can see what's behind it and interact with the apps behind my window. I searched the web and found some cool stuff but nothing that made me able to interact with apps behind, only half transparent!
Please help!
Sent from my GT-N7105 using xda premium
Click to expand...
Click to collapse
If you want to interact with the background, you'll need to go with a floating app here. Otherwise, there was a guide somewhere in the forum..
Hope this helps you.
addemod said:
Hey! I am currently doing an app that will be half transparent so you can see what's behind it and interact with the apps behind my window. I searched the web and found some cool stuff but nothing that made me able to interact with apps behind, only half transparent!
Please help!
Click to expand...
Click to collapse
To make your app transparent, modify your java as these:
Code:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WindowManager.LayoutParams params = this.getWindow().getAttributes();
/**
* 0.2 means 20% opaque. Here 1 is 100% opaque.
*/
params.alpha = 0.2f;
}
To make a button or any image transparent in your app you can add android:alpha="0.1" to your mainfest of the layout xml file
SimplicityApks said:
If you want to interact with the background, you'll need to go with a floating app here. Otherwise, there was a guide somewhere in the forum..
Click to expand...
Click to collapse
Do you mean this one? http://forum.xda-developers.com/showthread.php?t=2443882
nikwen said:
Do you mean this one? http://forum.xda-developers.com/showthread.php?t=2443882
Click to expand...
Click to collapse
Exactly, should be the same lib, isn't it? And yeah, fixed the link, I somehow deleted the last digit... Sorry
SimplicityApks said:
Exactly, should be the same lib, isn't it? And yeah, fixed the link, I somehow deleted the last digit... Sorry
Click to expand...
Click to collapse
No, it's not.
The tutorial I posted uses no library at all.
Differences:
More difficult
No default window frame
More customization options
nikwen said:
No, it's not.
The tutorial I posted uses no library at all.
Differences:
More difficult
No default window frame
More customization options
Click to expand...
Click to collapse
You're right, then that one is a lot easier..! :good:
Thanks guys! I used standout window and managed to make a Window but the problem is, you should be able to click behind the 50% transparent window.. anyway, thanks!
Sent from my GT-N7105 using xda premium

[Q]A little help in implementation

Hi I am making my first app, a launcher, I have to questions
1. I have it setup to return to home screen from app drawer but it also refreshes the whole main activity the code I have in place for this is:
Code:
[user=439709]@override[/user] public void onBackPressed() { super.onBackPressed(); setContentView(R.layout.activity_main); [code]
Is there a better way to do this(without refreshing the main activity) if so can someone point me in the right direction
2. What is the best way to implement page viewer for more home screens or is there a better way to do this as well?
I appreciate all and any response and help and thank anyone willing to lend a hand
Sent from my SGH-I747 using XDA Premium 4 mobile app
I think a launcher is definitely not an app a beginner should code.
But to your question: I guess you should leave super.onBackPressed() out.
EmptinessFiller said:
I think a launcher is definitely not an app a beginner should code.
But to your question: I guess you should leave super.onBackPressed() out.
Click to expand...
Click to collapse
Well, I think it depends on which kind of launcher he creates. If it is no fancy 3D launcher, I think of it as a better project for a beginner than a project that involves Server interaction. There are special, easy launchers which are designed for children as well.
Its no 3d or nothing really fancy the idea I have is a very simplistic and minimal launcher with just basic launcher features, the ui will be very similar to other launchers but yet different, so no other suggestions on how to implement closing app drawer when back button is pressed?
Sent from my SGH-I747 using XDA Premium 4 mobile app
Or is there any resources that would be recommended?
Sent from my SGH-I747 using XDA Premium 4 mobile app
deathblade said:
Its no 3d or nothing really fancy the idea I have is a very simplistic and minimal launcher with just basic launcher features, the ui will be very similar to other launchers but yet different, so no other suggestions on how to implement closing app drawer when back button is pressed?
Sent from my SGH-I747 using XDA Premium 4 mobile app
Click to expand...
Click to collapse
I would create two Fragments, one for the homescreens and one for the app drawer. Set it up that way that you can use popBackStack() to return to the homescreens from the app drawer.
Very detailed resource on Fragments: http://developer.android.com/guide/components/fragments.html

ZIGZAG ListView Design

Hi All,
I am working with a developer who has told me this is impossible to do and I am hoping one of you Android geniuses here could tell me if this is actually possible and perhaps point me in the right direction.
I am trying to create a list that has an unconventional shape which looks like the attached file.
Tapping each individual 'box' will take you to a different screen.
The developer I am working with says this isn't possible because they "overlap". As in if you draw a vertical line down the middle, boxes overlap.
He states that this is how it works:
1) Data comes from web service
2) We set the data in adaptor
3) There is a method in adaptor which populate view for each row
4) The adaptor is set in the Listview
Can someone please share their thoughts. Any advice would be greatly appreciated.
Regards,
Tal
I don't think its possible in listview . you may need to modify it. Can't say
Sent from my XT1033 using XDA Premium 4 mobile app
arpitkh96 said:
I don't think its possible in listview . you may need to modify it. Can't say
Sent from my XT1033 using XDA Premium 4 mobile app
Click to expand...
Click to collapse
Thanks for the reply,
If not possible in list view, do you know any alternative ways?
Cheers,
Tal
The main listview or grid view would not allow this .you need to extend one of these and build your own layout
Sent from my XT1033 using XDA Premium 4 mobile app
---------- Post added at 06:48 AM ---------- Previous post was at 06:46 AM ----------
One thing striked my mind.set dividers height to some negative value may help you achieve that.not sure though.
Sent from my XT1033 using XDA Premium 4 mobile app

Increment counter on longClick - not working

I've looked at several tutorials on how to count button clicks, but it's not working for me. Any ideas what I am doing wrong?
Code:
holder.mContainer.setOnLongClickListener(new View.OnLongClickListener() {
int count = 0;
@Override
public boolean onLongClick(View view) {
{
deleteItem(position);
count++;
Toast.makeText(ExampleActivity.appContext, "#" + String.valueOf(count), Toast.LENGTH_SHORT).show();
}
return true;
}
});
Basically, count remains at 1 always.
I'd be grateful for some pointers! Thanks!
My guess is because you declare int count = 0 in the first part which on every click is changing it back to zero so count++ will always be 0+1.
Sent from my HTC6535LVW using Tapatalk
thestraw0039 said:
My guess is because you declare int count = 0 in the first part which on every click is changing it back to zero so count++ will always be 0+1.
Sent from my HTC6535LVW using Tapatalk
Click to expand...
Click to collapse
Thanks for your reply, but removing that value unfortunately does not seem to help...
StrangerWeather said:
Thanks for your reply, but removing that value unfortunately does not seem to help...
Click to expand...
Click to collapse
Did you make count a global variable? Also try and change count++ to count = count +1.
Sent from my HTC6535LVW using Tapatalk
thestraw0039 said:
Did you make count a global variable? Also try and change count++ to count = count +1.
Sent from my HTC6535LVW using Tapatalk
Click to expand...
Click to collapse
Making it a global variable worked! Thanks, you're a star!

Categories

Resources