Categories
discuss

Why am I not seeing Firebase Analytics logging in logcat?

I have done this according to the docs:

adb shell setprop log.tag.FA VERBOSE
adb shell setprop log.tag.FA-SVC VERBOSE
adb logcat -v time -s FA FA-SVC

source

But this is all the output I see:

05-25 16:45:32.992 I/FA      ( 7019): App measurement is starting up, version: 9080
05-25 16:45:32.992 I/FA      ( 7019): To enable debug logging run: adb shell setprop log.tag.FA VERBOSE

I am certainly logging events as I have confirmed in the debugger that I’m calling the logEvent() API (and I do see them (much later) in the web dashboard).

and if I append a bunch of garbage to my event names I see this sort of output:

05-25 16:53:34.703 E/FA      (14150): Name must consist of letters, digits or _ (underscores). Type, name: event, clickedwhat the heck! no!!!

So I know my event names are at least being validated.. but I never see any of the unmolested events getting logged as being sent or any other sort of errors.

Answer

This seems to be a problem on all my N preview devices. Once I installed it on a pre-N device everything worked as expected.

It seems like adb shell setprop isn’t working on N preview 3

Categories
discuss

Default pressed MenuItem with 9-patch border after Android Studio 2.2

After updating to Android Studio 2.2 and Android Plugin to 2.2.0-alpha1, I noticed that when I press a MenuItem, it gets a black border. I presume that this border is caused by a problem with its 9-patch pressed background. Is this a known issue?

enter image description here
This is the pressed state. The default state works fine.

Obs: I am testing on a real device and I had never experienced this issue.

Thank you!

Answer

Try to change the default android plugin version 2.2 alpha to 2.1 stable.

classpath 'com.android.tools.build:gradle:2.1.0

Update : try latest version ( 2.2 ) when it become stable one

Categories
discuss

Why can event listeners stop working after using element.innerHTML?

I am a beginner in JavaScript. A JavaScript book says that one of disadvantages of element.innerHTML is:

Event handlers may no longer work as intended.

I can’t understand what this mean. Can someone give me an example?

Answer

Most probably, it refers to the technique some people use to insert HTML at the end:

element.innerHTML += "inserted HTML";

This will get the current HTML, concatenate it with the inserted one, and parse it all.

As a side effect, all the internal state of the existing elements (like event listeners, checkedness, …) will be lost.

var btn = document.querySelector("button");
btn.addEventListener("click", function() {
  btn.textContent = "I won't work anymore";
  document.body.innerHTML += "<p>Inserted text</p>";
});
<button>Click me to insert HTML</button>

Instead, if you want to insert some HTML at the end of an element, you can use

element.insertAdjacentHTML('beforeend', "inserted HTML");

This will preserve the existing elements.

var btn = document.querySelector("button");
btn.addEventListener("click", function() {
  btn.textContent = "I still work";
  document.body.insertAdjacentHTML("beforeend", "<p>Inserted text</p>");
});
<button>Click me to insert HTML</button>

Another alternative, if you don’t mind the inserted content to be wrapped inside an element, is using appendChild:

var btn = document.querySelector("button");
btn.addEventListener("click", function() {
  btn.textContent = "I still work";
  var wrapper = document.createElement('div');
  wrapper.innerHTML = "<p>Inserted text</p>";
  document.body.appendChild(wrapper);
});
<button>Click me to insert HTML</button>
Categories
discuss

FloatingActionButton, layout_anchor and layout_gravity

A bit of a newbie here. I’m about two months into Android development, but I have years of development experience in other environments.

Okay. I have a FloatingActionButton which was not showing up where I expected it or wanted it. It’s inside a CoordinatorLayout, along with an AppBarLayout/Toolbar, and following a ListView.

Here is the layout:

<?xml version="1.0" encoding="utf-8"?>

<android.support.design.widget.CoordinatorLayout               
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/fragment_coordinator"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".ViewVehicleList">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            android:title="Vehicle List"
            app:layout_scrollFlags="scroll|enterAlways|snap"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

    </android.support.design.widget.AppBarLayout>

    <ListView
        android:id="@+id/Vehicle_ListView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:background="#FFFFFF"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

    </ListView>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_AddVehicle"
        style="@style/FloatingAddButton"
        android:src="@drawable/ic_green_add"
        android:layout_gravity="bottom|end"
        app:layout_anchor="@id/Vehicle_ListView"
        android:onClick="addVehicle"/>

</android.support.design.widget.CoordinatorLayout>

With this layout, the screen looks like this: FAB in wrong position

My layout_gravity says "bottom|end". I changed it to "bottom|right", but still I got the same result. I’ve read many tutorials, and researched through Stack Overflow, and have had no luck.

I managed to solve it by removing the anchor listed in the FAB element app:layout_anchor="@id/Vehicle_ListView", which seems to run a counter to what I’ve read: to use a FAB and position it properly you need to use layout_anchor and layout_gravity. Without the anchor tag, it looks like this:

FAB in correct position

So here’s my question: Why is my anchor screwing up the positioning of my FloatingActionButton? What am I doing wrong?

Answer

You just need to add layout_anchorGravity.

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab_AddVehicle"
    style="@style/FloatingAddButton"
    android:src="@drawable/ic_green_add"
    android:onClick="addVehicle"
    app:layout_anchor="@id/Vehicle_ListView"
    app:layout_anchorGravity="bottom|end" />
Categories
discuss

Spring AOP Pointcut with method name starting with get

I’m trying to implement a Pointcut for spring AOP. All the methods which are like getXXXX should be logged. I tried the following but either they throw exception or does not trigger:

1st try

@Pointcut("within(net.services.*.get*)")
private void clServiceLayer() {}

@Pointcut("within(net.services.*.get*(..))")
private void clServiceLayer() {}

Need help with the proper expression for point cut.

Answer

within limits matching to join points within certain types. Instead you should use execution Pointcut Designator for matching method execution join points:

@Pointcut("execution(* net.tds.adm.metasolv.customerlink.services.*.get*(..))")

Checkout the Spring Documentation for more detailed discussion.

Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..