 While living in Perry, Hanley became involved in local Republican politics.He was a member of the New York State Assembly (Wyoming County) in 1927, 1928, 1929, 1930 and 1931, and a member of the New York State Senate (44th District) from 1932 to 1943, sitting in the 155th, 156th, 157th, 158th, 159th, 160th, 161st, 162nd, 163rd and 164th New York State Legislatures.After the death of Perley A. Pitcher, Hanley was elected Temporary President of the State Senate on February 27, 1939.