I am developing a simple android app. I have set preferences through a method which is given below-
public void updateSummaries() {
getPreferenceScreen().findPreference(PREF_SIP_DOMAIN).setSummary(settings.getString(PREF_SIP_DOMAIN, DEFAULT_SIP_DOMAIN));
getPreferenceScreen().findPreference(PREF_SIP_PROXY).setSummary(settings.getString(PREF_SIP_PROXY, DEFAULT_SIP_PROXY));
getPreferenceScreen().findPreference(PREF_SIP_PROXY_PORT).setSummary(settings.getString(PREF_SIP_PROXY_PORT, DEFAULT_SIP_PROXY_PORT));
getPreferenceScreen().findPreference(PREF_STUN_UDP).setSummary(settings.getString(PREF_STUN_UDP, DEFAULT_STUN_UDP));
getPreferenceScreen().findPreference(PREF_STUN_UDP_PORT).setSummary(settings.getString(PREF_STUN_UDP_PORT, DEFAULT_STUN_UDP_PORT));
getPreferenceScreen().findPreference(PREF_STUN_TCP).setSummary(settings.getString(PREF_STUN_TCP, DEFAULT_STUN_TCP));
getPreferenceScreen().findPreference(PREF_STUN_TCP_PORT).setSummary(settings.getString(PREF_STUN_TCP_PORT, DEFAULT_STUN_TCP_PORT));
getPreferenceScreen().findPreference(PREF_TURN_UDP).setSummary(settings.getString(PREF_TURN_UDP, DEFAULT_TURN_UDP));
getPreferenceScreen().findPreference(PREF_TURN_UDP_PORT).setSummary(settings.getString(PREF_TURN_UDP_PORT, DEFAULT_TURN_UDP_PORT));
getPreferenceScreen().findPreference(PREF_TURN_TCP).setSummary(settings.getString(PREF_TURN_TCP, DEFAULT_TURN_TCP));
getPreferenceScreen().findPreference(PREF_TURN_TCP_PORT).setSummary(settings.getString(PREF_TURN_TCP_PORT, DEFAULT_TURN_TCP_PORT));
getPreferenceScreen().findPreference(PREF_TCP_MODE).setSummary(settings.getString(PREF_TCP_MODE, DEFAULT_TCP_MODE));
getPreferenceScreen().findPreference(PREF_AFE_MODE).setSummary(settings.getString(PREF_AFE_MODE, DEFAULT_AFE_MODE));
getPreferenceScreen().findPreference(PREF_BWM_MODE).setSummary(settings.getString(PREF_BWM_MODE, DEFAULT_BWM_MODE));
getPreferenceScreen().findPreference(PREF_HTTP_PROXY).setSummary(settings.getString(PREF_HTTP_PROXY, DEFAULT_HTTP_PROXY));
getPreferenceScreen().findPreference(PREF_HTTP_PROXY_PORT).setSummary(settings.getString(PREF_HTTP_PROXY_PORT, DEFAULT_HTTP_PROXY_PORT));
getPreferenceScreen().findPreference(PREF_HTTP_DOMAIN).setSummary(settings.getString(PREF_HTTP_DOMAIN, DEFAULT_HTTP_DOMAIN));
getPreferenceScreen().findPreference(PREF_TURN_USERNAME).setSummary(settings.getString(PREF_TURN_USERNAME, DEFAULT_TURN_USERNAME));
getPreferenceScreen().findPreference(PREF_TURN_PASSWORD).setSummary(settings.getString(PREF_TURN_PASSWORD, DEFAULT_TURN_PASSWORD));
getPreferenceScreen().findPreference(PREF_HTTP_PROXY_USERNAME).setSummary(settings.getString(PREF_HTTP_PROXY_USERNAME, DEFAULT_HTTP_PROXY_USERNAME));
getPreferenceScreen().findPreference(PREF_HTTP_PROXY_PASSWORD).setSummary(settings.getString(PREF_HTTP_PROXY_PASSWORD, DEFAULT_HTTP_PROXY_PASSWORD));
getPreferenceScreen().findPreference(PREF_TRANSPORT_MODE).setSummary(settings.getString(PREF_TRANSPORT_MODE, DEFAULT_TRANSPORT_MODE));
getPreferenceScreen().findPreference(PREF_AUTO_ANSWER).setSummary(settings.getString(PREF_AUTO_ANSWER, DEFAULT_AUTO_ANSWER));
}
But here the warning message is shown and sometimes I don't get any preferences set on the setting page. Can anyone say me that what is the root cause of this problem?
Somebody deprecated that method using the #Deprecated annotation, because they believe it should no longer be used.
You should find where that method is declared and read the documentation under #deprecated if provided, or find whoever manages that method in your organization to find out what alternatives they are suggesting.
Edit: My apologies, didn't realize this is an Android snippet. See android - getPreferenceScreen question made by another user.
They are suggesting that you should use getPreferenceManager() instead.
Like so:
getPreferenceManager().findPreference("keep").setEnabled(true);
Related
I have used the folowing function to set color filter: public void setColorFilter (int color, PorterDuff.Mode mode) but recently, I have seen that it is deprecated. I have seen in the documentation the following warning to solve the deprecated method:
This method was deprecated in API level 29.
use setColorFilter(android.graphics.ColorFilter) with an instance of BlendModeColorFilter
I have noticed that there was a post were it was said to use the following line of code:
mydrawable.colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(color, BlendModeCompat.SRC_ATOP)
I have tried to do that, but the "colorFilter" is not recognized in my project and it is highlighted in red. How could I solve that?
This is the post I saw that possible solution: other post
Thanks in advance
On upgrading the billingclient to 2.1.0:
implementation 'com.android.billingclient:billing:2.1.0'//from 2.0.1
I suddenly got a cannot resolve symbol 'vending' error in my IabHelper class:
I've had to go back to billing:2.0.1 to prevent this. I notice the link to Trivial Drive 2 from the inapp billing docs https://github.com/android/play-billing-samples/tree/master/TrivialDrive_v2 now gives a '404' can't find error. Digging through githup I see Trivail Drive 2 is archived, a new Kotlin example is now featured, 'TrivialDriveKotlin'.
Is the Trivial Drive 2 implementation of inapp billing no longer supported by the latest billing code? Is there an java version of the TrivialDriveKotlin code somewhere?
I could and will do a translation if there isn't, but there should be a java version of this up front. Getting the original trivial drive 2 code working and debugged in the first place was such a pain.
My solution ended up being not to bother with the Trivial Drive example at all. The current implementation is simple enough to implement directly starting here https://developer.android.com/google/play/billing/billing_library_overview.
The tricky part right from the start is this line:
billingClient = BillingClient.newBuilder(activity).setListener(this).build();
It's odd to see both 'activity' and 'this' used in the same line as you would typically substitute 'this' for 'activity'. You will get compile or runtime errors if these aren't set correctly. Better would be:
billingClient = BillingClient.newBuilder(this).setListener(new PurchasesUpdatedListener() {...}).build();
or
PurchasesUpdatedListener puchaselistener;
puchaselistener = new PurchasesUpdatedListener() {...}
billingClient = BillingClient.newBuilder(this).setListener(purchaselistener).build();
I have a running application where once I clicked on a 'Edit' link of a table, I'm getting an error in the log of NoSuchMethodError and the control stays in the current page, not proceeding to the edit page.
Below piece of code has been hit while getting the error;
Field[] fields = entityObj.getClass().getDeclaredFields();
for(int i=0;i<fields.length;i++){
Field field =fields[i];
field.setAccessible(true);
if(field.getDeclaredAnnotation(EmbeddedId.class)!=null){
return true;
}
}
return false;
In the above code at the line,
if(field.getDeclaredAnnotation(EmbeddedId.class)!=null)
I'm getting the particular error.
Also mentioning the log as below;
Caused by: java.lang.NoSuchMethodError: java.lang.reflect.Field.getDeclaredAnnotation(Ljava/lang/Class;)Ljava/lang/annotation/Annotation;
at com.sprint.neo.querymodel.common.QueryObjectUtil.checkEnitityIsHasEmbeddedId(QueryObjectUtil.java:131)
at com.sprint.neo.querymodel.common.EntityManager.getEntityObject(EntityManager.java:89)
at com.sprint.neo.querymodel.common.EntityManager.loadEntityObject(EntityManager.java:72)
at com.sprint.neo.querymodel.common.EntityManager.entityload(EntityManager.java:60)
at com.sprint.neo.querymodel.common.EntityManager.loadAndGetEntityObject(EntityManager.java:56)
at com.sprint.neo.querymodel.common.QueryObjectUtil.getListOfEntityObject(QueryObjectUtil.java:718)
at com.sprint.neo.querymodel.common.QueryObjectCache.excuteUpdate(QueryObjectCache.java:251)
at com.sprint.neo.querymodel.common.QueryObjectRow.excuteUpdate(QueryObjectRow.java:298)
at com.sprint.neo.engine.controller.actions.TaskViewEditAction.edit(TaskViewEditAction.java:83)
The control should proceed to the edit jsp page as all the jsp are implemented correctly.
What I'm doubting about the error from the log is that, if any jar file is missing regarding Reflection api.
Please suggest me a solution to overcome this problem. Any valuable advise will be helpful. Thanks a lot.
You are using the method Field.getDeclaredAnnotation(Class). This method was introduced in Java 8. It is not available in Java 7 and earlier. You need to upgrade your JDK.
Field is a subclass of AccessibleObject and inherits the method from that class. See the Javadoc: It says “Since: 1.8” which is the version for Java 8 in the internal numbering scheme.
I use iText 5 in Android Studio to create a PDF document but I get an error:
I also tried
p.add((Phrase)c);
but I get same error :-(
How I can get rid of this error?
"ambiguous" error comes up when u already have a file/varibale etc with same name.
for example when you make a project using entity framework , entity framework make class and dbcontext files for u. but if u add a class with same name as entity framework had made for u then this error comes up. check ur project/programe correctly and fully again...
Hope its helpfull !!
and checkout this link for ur answer Android Studio - Ambiguous method call getClass()
thanks for reply - indeed I needed help regarding why 'ambiguous' appears in this context.
But now the problem is solved - this error does not appear anymore - but I don't know exactly why.
I did some Android Studio updates last week may this helped?
Thanks anyway!
In case when we use data binding, some java files are auto-generated
The problem was occured when a getter/setter has the same name with a function.
eg
var newData
fun getNewData()
in this case, in the generated java file, the variable's getter has the same name with the function => getNewData.
So simply you have to change variable name or fuction name
I am using Fortify SCA to find the security issues in my application (as a university homework). I have encountered some 'Log Forging' issues which I am not able to get rid off.
Basically, I log some values that come as user input from a web interface:
logger.warn("current id not valid - " + bean.getRecordId()));
and Fortify reports this as a log forging issue, because the getRecordId() returns an user input.
I have followed this article, and I am replacing the 'new line' with space, but the issue is still reported
logger.warn("current id not valid - " + Util.replaceNewLine(bean.getRecordId()));
Can anyone suggest a way to fix this issue?
I know this was already answered, but I thought an example would be nice :)
<?xml version="1.0" encoding="UTF-8"?>
<RulePack xmlns="xmlns://www.fortifysoftware.com/schema/rules">
<RulePackID>D82118B1-BBAE-4047-9066-5FC821E16456</RulePackID>
<SKU>SKU-Validated-Log-Forging</SKU>
<Name><![CDATA[Validated-Log-Forging]]></Name>
<Version>1.0</Version>
<Description><![CDATA[Validated-Log-Forging]]></Description>
<Rules version="3.14">
<RuleDefinitions>
<DataflowCleanseRule formatVersion="3.14" language="java">
<RuleID>DDAB5D73-8CF6-45E0-888C-EEEFBEFF2CD5</RuleID>
<TaintFlags>+VALIDATED_LOG_FORGING</TaintFlags>
<FunctionIdentifier>
<NamespaceName>
<Pattern/>
</NamespaceName>
<ClassName>
<Pattern>Util</Pattern>
</ClassName>
<FunctionName>
<Pattern>replaceNewLine</Pattern>
</FunctionName>
<ApplyTo implements="true" overrides="true" extends="true"/>
</FunctionIdentifier>
<OutArguments>return</OutArguments>
</DataflowCleanseRule>
</RuleDefinitions>
</Rules>
</RulePack>
Alina, I'm actually the author of the article you used to solve your log injection issue. Hope it was helpful.
Vitaly is correct with regards to Fortify. You'll need to build what Fortify calls a "custom rule".
It will likely be a dataflow cleanse rule. A basic example can be found here: http://www.cigital.com/newsletter/2009-11-tips.php. If you own Fortify, there should be a custom rule writing guide in your product documentation.
I don't know what the taint flag you'll use is, but it would look something like "-LOG_FORGING". You would essentially write a rule to remove the log forging "taint" whenever data is passed through your utility method. Fortify will them assume that any data passed through there is now safe to be written to a log, and will not cause log forging.
You need to mark your replaceNewLine as sanitiser in Fortify (if I remember correctly) and it will stop reporting the issue.
You can actually create a new rule from a particular method.
Navigate to the function on the right side of audit workbench after you've done a scan.
Find your sanitizing method and right click on it.
You can generate a rule from it. What you want is a general DataflowCleanseRule.
I just did this based on the xml someone posted above. You can save the rule as a .xml file.
When updating your scan you can pass the -rule argument and point at the .xml file.